New course! Every coder should learn Generative AI!
Try a free lesson+ 2
How do I compare strings in Java?
3 Answers
+ 2
.equals()
+ 2
but why dont ==
+ 2
== tests for reference equality (whether they are the same object).
.equals() tests for value equality (whether they are logically "equal").