In Java variable range can be divided into effect according to three categories: class variables, member variables and local variables.
Class variables
Defined in the class, the method of addition thereof, but it must be declared static variable types. Class variables belong to the class as a whole, may be invoked by an object name or class name. And because the class using static variables are declared, class variables, also known as static variables.
public class Class1{
// class variables
static int a;
// method body
public void method1(){
System.out.println(a);
}
}
Member variables
Defined in the class, the methods outside the body. When you create a variable object is instantiated. Statement block member may be variable in the class methods, class-specific configuration and access methods. And class variables, member variables can only be called an object, so the member variable is also known as instance variables.
public class Class2{
//Member variables
String int b;
// method body
public void method2(){
System.out.println("b");
}
}
Local variables
Variables defined in the method, constructor, statement blocks. Declare and initialize its realization in the method, the method is automatically destroyed at the end. Local variables and other languages are no different from the description.
public class Class3{
// method body
public void method3(){
// local variables
int c;
System.out.println(c);
}
}