PPT Slide
As part of the Java Language Specification (the ‘rules’ for the Java Language), Strings have a special characteristic. It turns out that in some circumstance (BUT NOT ALL), you can use ‘==‘ to compare Strings, in addition to .equals(). Consider:
String strHello1 = “Hello”;
String strHello2 = “Hello”;
We would expect these lines to produce the
In fact, it produces the following results in memory:
Equality with References to Objects: