In the first case, the compiler knows the value of the string s1. Thus, all rows with the same value will use the same memory cells:
String s1 = "abc";
String s2 = "abc";
Although there are two references to String (s1 and s2), there is only one “abc” sequence in memory. An operator is newnot needed because the compiler is doing the job.
String. , String :
String s1 = "abc";
String s2 = new String("abc");
"abc" 1 , "abc" 2. 2 - String.