News for hackers. Stuff that matters.
Re:Out of My Depth by mbrameld on Thursday April 25, 2013 @02:50PM (#5609124)
You probably know this, but I think the author is confusing a string literal with a lowercase string.

String a = "hello";

String b = "hello";

a == b will evaluate to true.

String a = new String("hello");

String b = new String("hello");

a == b will evaluate to false.

String literals in Java are put in to a string "heap" (might not be the correct word) and reused. Strings objects create a new instance for each string.

There are no comments on this comment yet.