What exactly is the difference between the two statement
String s1="abc";
String s2=new String("abc");
From what i Know is that the first statement will create a object in String pool i.e and s1 will reefer it. In Second statement the it will create two object because I used new keyword and s2 will refer the object in String pool
Now if I execute both statement one after another .Since will the first statement the object "abc" will be in string pool and with the execution of second statement s2 will refer to object which is alreday there in string pool is if i do s1==s2 it should return true however its returning false.
can you please explain why?