Difference between String s="hello"; and String s=new String("hello"); in Java.The statement String s = “hello” is initialized to s and creates a single interned object. While String s = new String(“hello”); creates two string objects, one – interned object, two – object on the heap.
|