
Untitled
By: a guest on
Jun 4th, 2012 | syntax:
None | size: 0.47 KB | hits: 10 | expires: Never
Strings are immutable! But I can still modify and get a new copy of the original String? [closed]
String s = "PROJECT";
String s = "PROJECT";
String s2 = s.toLowerCase();
System.out.println(s.equals("PROJECT")); // Prints true
System.out.println(s.equals(s2)); // Prints false
MutableString ms = "PROJECT";
MutableString ms2 = ms.toLowerCase();
System.out.println(ms.equals("PROJECT")); // Prints false
System.out.println(ms.equals(ms2)); // Prints true