CSC300 / CSC402: String Constructor [7/24] Previous pageContentsNext page

String x = new String ("Hello");
String y = new String ("Hello");
x=Hello, y=Hello
                  x==y : false
   Objects.equals(x,y) : true
           x.equals(y) : true
eqs02

One of the guarantees of Java is that using new will always construct a new object.

Previous pageContentsNext page