java.lang.Integer and
java.time.LocalDate, are value-based.
A value-based class has the following properties:
equals, hashCode,
and toString compute their results solely from the values
of the class's instance fields (and the members of the objects they
reference), not from the instance's identity;x and
y that are equal according to equals() produces no
visible change in the behavior of the class's methods;equals(), they may also be
equal according to ==;Object or a hierarchy of
abstract classes that declare no instance fields or instance initializers
and whose constructors are empty.When two instances of a value-based class are equal (according to `equals`), a program should not attempt to distinguish between their identities, whether directly via reference equality or indirectly via an appeal to synchronization, identity hashing, serialization, or any other identity-sensitive mechanism.
Synchronization on instances of value-based classes is strongly discouraged, because the programmer cannot guarantee exclusive ownership of the associated monitor.
Identity-related behavior of value-based classes may change in a future release. For example, synchronization may fail.