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



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

Answer / 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

More Core Java Interview Questions

What is difference between Eclips and MyEclips?

3 Answers  


Catch(Exception e){ } in that what is Exception and purpose of that in that place exactly?

3 Answers  


What are the disadvantages of using inner classes?

0 Answers  


Why chararray() is preferred over string to store the password?

0 Answers  


What are the types of statement? explain

1 Answers   SysBiz,






What is continuity of a function?

0 Answers  


Difference between Hash Table and Hash Map?

10 Answers   Persistent,


Can we use synchronized block for primitives?

0 Answers  


What is meant by stack and queue?

0 Answers   GrapeCity,


what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent

0 Answers  


Can a static method be overridden in java?

0 Answers  


Explain method overloading and overriding?

6 Answers  


Categories