Delete comment from: Java67
true taller said...
there will be two objects created s will be in heap and by "abc" literal object will be go in the string constant pool.
if there is already a "abc" present than it will not create new and give the reference of previous "abc".
Take A example:
class intern
{
public static void main(String... s)
{
String s6 = "arpan";
String s5 = "arpan";
if(s5==s6)
System.out.println("true");
}}
Feb 3, 2016, 12:34:30 PM
Posted to Difference between String literal and New String object in Java