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 are the drawbacks of reflection?

0 Answers  


Can inner class be public in java?

0 Answers  


what is mean by method signature?

8 Answers   Satyam,


What's the difference between int and integer in java?

0 Answers  


What is sortedset in java?

0 Answers  






Write a function for palindrome and factorial and explain?

0 Answers   Honeywell, Huawei, Zomato,


How to convert String into primitive datatype.

6 Answers  


What is an argument in java?

0 Answers  


What is pass by value?

0 Answers  


What is the basic concept of java?

0 Answers  


What is the impact of declaring a method as final?

0 Answers  


Explain restrictions for using anonymous inner classes?

0 Answers  


Categories