Java syntax: Difference between revisions

Content deleted Content added
Line 846:
 
==Reference types==
Reference types include class types, interface types, and array types. When the constructor is called, an object is created on the heap and a reference is assigned to the variable. When a variable of an object gets out of scope, the reference is broken and when there are no references left, the object gets marked as garbage. The garbage collector will then collectcollects and destroydestroys it some time afterwards.
 
A reference variable is <code>null</code> when it does not reference any object.