0
what is the difference between == ans equals
3 Answers
+ 2
Main difference betweenĀ ==Ā and equals in Java is thatĀ "=="Ā is used to compareĀ primitivesĀ whileĀ equals()Ā method is recommended to check equality of objects.
Another difference between them is that, If bothĀ "=="Ā andĀ equals()Ā is used to compare objects thenĀ ==Ā returns true only if both references points to same object whileĀ equals()Ā can return true or false based on itsĀ overridden implementation.
One of the popular cases isĀ comparing two String in JavaĀ in which case == and equals() method return different results.
+ 1
please any example
- 1
== means that 2 objects are exactly the same . eqauls means the content is the same. Int are compared by = and strings fir example with equals.



