Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Strings are immutable! But I can still modify and get a new copy of the original String? [closed]
  2. String s = "PROJECT";
  3.        
  4. String s = "PROJECT";
  5. String s2 = s.toLowerCase();
  6.  
  7. System.out.println(s.equals("PROJECT")); // Prints true
  8. System.out.println(s.equals(s2));        // Prints false
  9.        
  10. MutableString ms = "PROJECT";
  11. MutableString ms2 = ms.toLowerCase();
  12.  
  13. System.out.println(ms.equals("PROJECT")); // Prints false
  14. System.out.println(ms.equals(ms2));       // Prints true