Reference
A reference value points to a sequence of memory locations that may contain an object or array.
Related concepts: ValueTypeObjectArrayPrimitive
Closest Wikipedia entry: Reference (computer science) — In computer programming, a reference is a value that enables a program to indirectly access a particular datum, such as a variable's value or a record, in the computer's memory or in some other storage device. The reference is said to refer to the datum, and accessing the datum is called dereferencing the reference. A reference is distinct from the datum itself.
Misconceptions about Reference29 documented Misconceptions
Check YourselfAssignmentCopiesObject
Assignment copies the objectBoxedNull
Passing null to a wrapper class constructor creates an object representing the absence of a valueEqualityOperatorComparesObjectsValues
o==p compares the objects referred to by variables o and pEqualsComparesReferences
o.equals(p) compares the references stored in the variables o and pFinalReferenceImpliesImmutability
An object referred to by a final variable is an immutable objectMultiReferenceVariable
A reference variable can point to multiple objectsNullIsObject
null is an objectReferenceIntoStack
References can point into the stackReferenceLabeledWithDynamicType
In stack and heap diagrams, reference variables are labeled with the types of the objects they refer toReferenceToBooleanCoercion
Every reference type can be coerced to booleanReferenceToIntegerConversion
One can cast between references and intsReferenceToVariable
References can point to variablesSubtypeCompatibleWithSupertype
A variable of a subtype can reference an object of a supertypeSupertypeIncompatibleWithSubtype
A variable of a supertype cannot reference an object of a subtypeThisAsField
this is a special field in the objectThisAssignable
One can assign to thisThisCanBeNull
this can be nullThisExistsInStaticMethod
this is a local variable, also in static methodsThisInConstructorIsNull
In a constructor, this is nullVariablesHoldObjects
A variable of a reference type contains a whole object