Share
What is the difference between == and .equals() in Java?
Question
can you please help me with thus question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Answer ( 1 )
==
compares object references (memory addresses)..equals()
is used to compare content of objects.String a = new String("Hello");
String b = new String("Hello");
System.out.println(a == b); // false (different objects)
System.out.println(a.equals(b)); // true (same content)