Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the differences between == operator and equals() method?

0
Posted

What is the differences between == operator and equals() method?

0

• No equals() method for primitive types. Of course, primitive type wrapper classes (e.g. Integer class) do. • == operator compares the values of primitive types. • == operator compares the reference (values) of Objects. • Unlike C++, Java does not allow operator overwriting. Which means two identical objects A and B, A==B will never happen. • Object.equals() will behave exact the same as ==, unless it is overridden by the subclass. • More equals / == examples here, TestEqual.java • Warning: Don’t try this at work!

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123