Variables members of Java, local variables and class variables

Java in the variables:

 

1, member variables (instance variables, attributes)

2, a local variable (local variable)

3, class variables (static properties)

 

First, the member variables (instance variables, attributes)

1.1 :( member variables defined in the class, access modifiers modifiers type name = value)

1.2 What is the member variables?

  Member variable is a class of property. When new objects when each object has a property. A property in an object that is a member variable.

1.3 scope?

  In the inner class, anywhere access to member variables.

1.4 Life Cycle? (Present time in memory)

  Born: new object, it opens up memory space. 

  Death: heap memory address does not reference into garbage after garbage collected.

Second, the local variable (local variable)

2.1 Local variables :( modifiers type name = value)

2.2 What is a local variable?

  The method of formal parameters and variables defined in the method.

2.3 scope?

  Parameter: can be accessed anywhere in the method body.

  The method defined variables: define the beginning, until the end of the block is located.

2.4 Life Cycle? (Present time in memory)

  Birth: When you create a run to the statement variables. 

  Death: beyond its scope. to sum up:

Third, class variables (static properties)

3.1 class variable :( access modifier static type name = value)

3.2 What is the class variables?

  It is modified static properties.

3.3 scope?

  After class variable definitions.

3.4 Life Cycle? (Present time in memory)

  Birth: When the class loader, class variables allocated memory space. 

  Death: JVM exit

 

Over...

reference:

1. the Java variables in

 

Guess you like

Origin www.cnblogs.com/gjmhome/p/11410083.html