java variable classification

Local variables (lacal variable):

The method defined in statement block internal variable. Life cycle from the beginning to the position statement "}" so far.

You must declare and initialize (initial value) before use.

Note: For local variables java virtual machine does not give it initializes itself, that is, does not give it conferred on the default value for the type of local variables to make their own initialization.

Instance variables (member variables member variable):

The method defined within an external, class variables. Subordinate to the object, the object is always associated with the life cycle.

Initialize itself if not, he will automatically initialized to the default initial value of the type (numeric variable is initialized to 0 or 0.0, the initial value is variable character \ u0000, boolean default is false)

Static variables (class variables static variable):

Use static definitions. Subordinate class, class is always accompanied by life-cycle, from loading to unloading the class. (NOTE: The next memory analysis will tell you like, you can understand this concept now)

Initialize itself if not, he will automatically initialized to the default initial value of the type (numeric variable is initialized to 0 or 0.0, the initial value is variable character \ u0000, boolean default is false)

Guess you like

Origin www.cnblogs.com/lrzienhi/p/11819155.html