what is difference between
String str="abc"; and String str=new String("abc");
1)String str=new string("abc") creates two objects, one in heap memory and one in string pool.It utilize memory in a better way with fulfilling object creation. While String st="abc" creates one object which goes to string pool.It consumes less memory.
2)String str = abc is a String literal where as String str = new String("abc") is a String Object.
Thank u very much!!!!!
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.