Consider the following case:
String cat = "cat";
String cat2 = "cat";
out.println(cat == cat2); // true // Uses String#equals(...)
out.println(((Object) cat) == ((Object) cat2)); // true. Object#equals(...)???
// So it should be false!
The ==
defaults to the .equals
of the Object being compared by answer in StackOverflow.
Since, I am casting these as Objects, shouldn't they use default comparison which is reference comparison?