N
Neroku
Hi, I know java ensures that only one String object exists when there
are two identicals Strings, i.e:
String s1 = "Hello";
String s2 = "Hello";
System.out.println(s1==s2);
It prints "true"
However:
String s1 = "Hello";
String s2 = new String("Hello");
System.out.println(s1==s2);
prints "false"
I don't understand why, since both Strings hold the same data. Any
ideas?
TIA
are two identicals Strings, i.e:
String s1 = "Hello";
String s2 = "Hello";
System.out.println(s1==s2);
It prints "true"
However:
String s1 = "Hello";
String s2 = new String("Hello");
System.out.println(s1==s2);
prints "false"
I don't understand why, since both Strings hold the same data. Any
ideas?
TIA