Difference between == and .equals() ?



Difference between == and .equals() ?..

Answer / Shailendra Kumar Pandey

== compares the memory location of two objects, while .equals() compares the state (values) of two objects. Objects created with new operator have different memory locations, so == usually returns false for them.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

How to create an immutable class?

1 Answers  


Can a for statement loop indefinitely?

3 Answers  


What is an exception in java?

1 Answers  


Can we assign null to double in java?

1 Answers  


what do you mean by classloader in java?

1 Answers  


When garbage collector invokes object?s finalize() method?

5 Answers  


Why are constructors used?

1 Answers  


Why you should not use singleton?

1 Answers  


How do you format in java?

1 Answers  


I have one Shopping cart application, i that i have selected some items, while clicking submit button by mistake i have clicked twice or trice, that time items are selected twice or trice. Actually i want only one copy of items but its selected twice or trice. So how can we avoid this problem?

2 Answers   Honeywell,


Explain Event handling in AWT?

1 Answers   Infosys, TCS,


What are methods in java?

1 Answers  


Categories