4 ms·
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 ev
by mbrameld 14y ago
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.