Local variables and member variables are primarily the difference between their scopes
A member variable is a class interior; a local variable is the inside of the method body that defines it (or inside a program block inside a method body-the curly braces, mainly the location of the definition).
In addition, member variables can be not explicitly initialized, they can be set by the system default values, local variables do not have a default value, so you must set the initial assignment.
There are two types of member variables for a Java class: A variable that is modified by the static keyword, called a class variable or a static variable, and an instance variable without a static modifier.
The difference between the syntax definitions: Static variables are added with the static keyword, and the instance variable is not added before.
The difference when the program runs: instance variables belong to an object's properties, and an instance object must be created where the instance variable is allocated space before the instance variable can be used. static variables are not part of an instance object, but belong to a class, so also known as class variables, as long as the program loads the class's bytecode, without creating any instance objects, static variables will be allocated space, static variables can be used. In summary, an instance variable must be created before it can be used by the object, and a static variable can be referenced directly using the class name.
Java local/Member/static/instance variables