loading...

Discussion on: Primitive Types and Variables in Java

Collapse
ivenk profile image
iven_k

I think string pooling generally does not apply when the variable is created using ... = new String("bla");

In your example :
String a = new String("Leroy");
String b = new String("Leroy");

a == b // this is now false;

Here is a good article on this specific topic : baeldung.com/java-string-pool

Thread Thread
renegadecoder94 profile image
Jeremy Grifski Author

Awesome! Thanks, I've updated the italicized bit.

Thread Thread
ivenk profile image
iven_k

No problem. Have a great day !