whether two variable are referring to the same object.
Identity is a property of an object that uniquely defines its abstract location.
Two objects stored in variable a
and b
are said to have the same identity, if a
and b
actually refer to the same object (same class, same abstract memory location). On can test identity of two objects using
As an implementation detail, identity hints about potential co-location of objects in physical or virtual memory, and thus may be related to performance. In some languages, one can get a value representing the object's identity, or address (although this token is only valid during the object's lifetime):