Equals equals equals equals equals equals equals equals equals equals equals

First, there are two types of data types in Java: base data types (byte, char, short, int, Long, float, double, Boolean) and reference data types (object references).

  • In the underlying data type, == and equals are the comparison values

  • Reference types, ==, and equals compare memory addresses, but equals is overridden by the String, Interge, and Date classes, so what equals compares depends on the implementation.

Code sample

The equals implementation in String

The equals implementation in Object