Difference between creating String object with new operator & literal pool
812848Dec 15 2010 — edited Dec 15 2010Hi,
Can anyone please help me to understand what's the difference between following string object creation -
1. String s = new String("hi");
2. String s = "hi";
what i know is in first case a new object will be created and will be in heap memory and in the second case object will be in string literal pool which is also inside heap memory.
thanks in advance,
Sikky