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
What are thread local variables?
What is difference between final and immutable?
What is static block?
Explain different types of wrapper classes in java?
What is an example of procedure?
What is method with example?
Why is java multithreaded?
What steps are taken when the OS shifts from one-thread execution to another?
How is a variable stored in memory?
What is consumer in java?
What is a parameter in a function?
Explain the term virtual machine?
What is illegal identifier in java?
What is the difference between abstraction and encapsulation?
what is session in java?