Q 19 - == vs .equal() #23
Answered
by
AmjustGettingStarted
HARSHITH-MV
asked this question in
Q&A
-
What is the difference between "==" and ".equals()" in Java? 🤔 |
Beta Was this translation helpful? Give feedback.
Answered by
AmjustGettingStarted
Jul 12, 2025
Replies: 1 comment
-
In Java:
Example: String s1 = new String("Hello");
String s2 = new String("Hello");
System.out.println(s1 == s2); // false (different references)
System.out.println(s1.equals(s2)); // true (same content) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
HARSHITH-MV
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Java:
Example: