what is the difference between equals method and ==
Answer Posted / rajender
The Object class equals method refers address comparision.
Person p=new Person();
Person p1=new Person();
if(p.equals(p1){
//is always false.
}
the string class equals method refers content comparision
String p=new String ("java");
String p1=new String ("java");
if(p.equals(p1){
//is always true.
}
Dn't get confusion
Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
Explain wait() method of object class ?
Is arraylist an object in java?
What is the do while loop syntax?
Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?
What is string data?
What do you mean by JVM?
What do you mean by access modifier?
What is the difference between compile-time polymorphism and runtime polymorphism?
How do you achieve singleton?
What is the covariant return type?
What is the difference between assignment and initialization?
What happens to the Exception object after handling an exception?
What value is a variable of the string type automatically initialized?
What is final keyword in java?
do I need to use synchronized on setvalue(int)? : Java thread