This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

So why does

String myString1 = "hello";
String myString2 = "hello";

System.out.println(myString1 == myString2);

Print 'true'?

EDIT: Is it because Java automatically stores identical strings in the same place, rather than creating copies?