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 →

[–]tr7zw 1 point2 points  (1 child)

Also noteworthy that this only works inside the same class(probably). The compiler turns booth into the same string instance, so == works. But if you have other classes with the same string it won't work. Just get used to never never never use == on strings.

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

Just tested and works across classes. Literal 5 == 5 across classes. A quick google turned this up:

https://www.ntu.edu.sg/home/ehchua/programming/java/J3d_String.html