{@index "Value-based Classes"}

Some classes, such as {@code java.lang.Integer} and {@code java.time.LocalDate}, are value-based. The compiler and runtime enforce the value based properties below if it is declared as {@code value class} and preview features are enabled. A value-based class has the following properties:

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 {@code ==} 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 when implemented as a value class.