+ 2
Difference between String s = "abc"; and String s = new String("abc");
String class
4 Respostas
+ 8
String s = new String("abc");
- creates new object.
String s = "abc";
- replaces existing object.
+ 8
you should also take a look at were these strings are stored in string pool and heap memory and the diffrence between them both when creating objects
+ 5
It is really a good concept. When you write String s=new String("abc"); it will create a new object every time having different reference(memory location) but when you write String s="abc"; it will point to already existing object in memory pool means reference is same.
https://stackoverflow.com/questions/3052442/what-is-the-difference-between-text-and-new-stringtext
+ 3
String class are store in heap and it copies one string to scp(string constant pool) and if one string has the same data then String="abc" wont create it replicate other