CSC300 / CSC402: String Interning [9/24] |
String a = new String ("Hello"); String b = new String ("Hello"); String x = a.intern(); String y = b.intern(); x=Hello, y=Hello x==y : true Objects.equals(x,y) : true x.equals(y) : true |
String
's intern
method looks for a canonical representation of the string.