CSC300 / CSC402: String Operators [8/24] Previous pageContentsNext page

String x = "Hel" + "lo";
String y = "Hel" + "lo";
x=Hello, y=Hello
                  x==y : true
   Objects.equals(x,y) : true
           x.equals(y) : true
eqs03

Java is being efficient by looking for a canonical representation of the string.

Previous pageContentsNext page