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


Please Help Members By Posting Answers For Below Questions

What is the applet security manager, and what does it provide?

544


What is binary tree in java?

537


When we should use serialization?

572


How will you communicate between two applets?

632


How many types of gc are there in java?

569






What is protected in java?

530


What type of value does sizeof return?

543


What does yield method of the thread class do?

583


How do you use find and replace?

515


How many digits can a float hold?

537


Whats the difference between notify() and notifyall()?

572


Write a program to reverse array in place?

593


What is reverse function?

576


Is string is a class in java?

526


What is application tier?

532