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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4