Answer the question
In order to leave comments, you need to log in
What is the meaning of Object.equals(Object ob) method in Java?
What is the difference between the "==" comparison operator and the Object.equals(Object ob) method? The documentation says that the equals method compares the contents of objects and outputs the boolean true if the contents of the objects match, and false otherwise. However, this is not the case in practice:
public class Application {
public static void main(String args[]) {
A a1 = new A(3);
A a2 = new A(2);
System.out.println(a1.equals(a2));
}
}
public class Application {
public static void main(String args[]) {
A a1 = new A(3);
A a2 = new A(2);
a1 = a2;
System.out.println(a1.equals(a2));
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question