What is difference between “==” and equals()?

Answer Posted / javamasque

“==”: It compares references (memory locations). It does not compares values in the memory location. Hence it is not recommended to find the equality of two objects. It is mostly used to compare primitive types.

equals(): It is used to find the equality of two objects. It actually compares with the values that an object contains.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we override singleton class?

539


What is the definition of tree ?

592


What is passing parameters in java?

526


What are advantages and disadvantages of OOPs?

630


What type of language is java?

547






What are the ways in which a thread can enter the waiting state?

515


Realized?

1666


What is hashtable and explain features of hashtable?

567


How do you add spaces in java?

516


What is string subsequence method?

632


What is the difference between jdk, jre, and jvm?

576


What is the difference between procedural and object-oriented programs?

528


Which class is the superclass of all classes?

604


Can a class have multiple constructors?

538


Will minecraft java be discontinued?

653