Well defined but not obvious:
Object test for equality:
== is used to test references ( do these two object references point to the same object )
While equals is used to test object equality.
So for instance
new String("test") == new String("test")
Is false, while
new String("test").equals( new String("test") )
Is true
String objects are interned so the following returns true:
String a = "test";
String b = "test;
a == b // returns true
BUT if the string is created somewhere else ( from a database for instance )
String a = "test";
String b = getFromDataBase(); // internally the remote returns "test"
a == b // returns false.
The validation is false.
I've seen this happening in jsp with scriplets, and new programmers don't get why the validation
<%if( param == "continue" ) { %>
Never happens