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 maximum size of arraylist in java?

505


What is difference between class and object in java?

533


How the interruptible method gets implemented?

571


How to access arraylist elements in java?

499


In the below example, what will be the output?

597






Is a class an object?

586


what is the difference between preemptive scheduling and time slicing? : Java thread

541


What is the benefit of abstract class?

523


What is 16 bits called?

513


Hi friends am new to java. I read jar file means collection of java files. For executing struts application what are the necessary jar files. " struts.jar " file contains what. can u explain

1446


Is logger a singleton?

532


What is the major difference between linkedlist and arraylist?

516


Are arrays static in java?

596


Does java initialize arrays to zero?

516


Why webdriver is an interface?

589