2 Replies Latest reply: Dec 15, 2010 4:52 AM by 802316 RSS

    Difference between creating String object with new operator & literal pool

    812848
      Hi,

      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