I have used below string operation but not able to understand why 1st case is not working.
Case - 1 :
String myString = new String("old String");
System.out.println(myString);
myString.replaceAll( "old", "new" );
System.out.println( myString );
//Output
old String
old String
Case - 2 :
String myString = new String("old String" );
System.out.println(myString);
myString = new String("new String");
System.out.println(myString);
//Output
old String
new String
Why case - 1 is working but case - 2 is not working?