String s = "";
String s2 = someUserInputVariale.toLowercase(); // where the user entered in ""
Something like that would cause s == s2
to evaluate to false.
Lots of code sill create new Strings
without exposing the call to new String()
.
More Related Contents:
- Is there a Java utility to do a deep comparison of two objects? [closed]
- When does HashSet ‘add’ method calls equals? [duplicate]
- What does comparison being consistent with equals mean ? What can possibly happen if my class doesn’t follow this principle?
- How default .equals and .hashCode will work for my classes?
- Why Java does not see that Integers are equal?
- Demonstrating string comparison with Java
- Why 2 return statements are mandatory in equals method
- How to compare dates in Java? [duplicate]
- equals vs Arrays.equals in Java
- Compare two objects with .equals() and == operator
- What’s the difference between “.equals” and “==”? [duplicate]
- Sort on a string that may contain a number
- Any reason to prefer getClass() over instanceof when generating .equals()?
- How to override equals method in Java
- Jackson Vs. Gson [closed]
- How do I make my string comparison case-insensitive?
- Getting an element from a Set
- Using == operator in Java to compare wrapper objects
- Why do == comparisons with Integer.valueOf(String) give different results for 127 and 128?
- Java: How to test on array equality?
- Hashcode and Equals for Hashset [duplicate]
- Comparing boxed Long values 127 and 128
- Is it valid to compare a double with an int in java?
- Java: If vs. Switch
- How to implement hashCode and equals method
- Why can’t we use ‘==’ to compare two float or double numbers [duplicate]
- Why are two AtomicIntegers never equal?
- Difference between String#equals and String#contentEquals methods
- (obj == null) vs (null == obj)?
- Comparing a string with the empty string (Java)