Possible Duplicate:
Java Strings: “String s = new String(”silly“);”
I was going through some of the string examples and I am confused:
What is the difference between
String one = new String("ONE");
and
String one = "ONE";
and here is the example why i am bit confused
String one = new String("ONE");
String another_one = new String("ONE");
System.out.print(one.equals(another_one)); //-->true
System.out.print(one == another_one ); //-->false
while
String one = "ONE";
String another_one = "ONE";
System.out.print(one.equals(another_one)); //-->true
System.out.print(one == another_one ); //-->true
Why is it such so?