Why String class is immutable in Java, as everytime we call certain methods on a String reference variable , new String is created?
public class Test {
public static void main(String [] args) {
String s = "abc";
s.toUpperCase(); // new String is created here.
System.out.println(s);// prints abc instead of ABC
}
}