Local variables
Definition: A variable defined within a method is called a "local variable" or "temporary variable", and the memory occupied by the local variable is freed after the method ends.
Global variables
Definition: A global variable, also known as an "external variable," which is not a method of which the scope begins at the defined address to the end of the source file.
Precautions:
Local variables work when local variables have the same name as global variables.
Member variables
Definition: A variable defined in the variables section of a class body, also known as a field.
Difference:
There is no definition of global variables in Java, which is in C
Cases:
class demo{ int x; a non-static member variable, also called a property, is a different staticint y for different objects of that class; a static member variable that has only one of the variables in a class that shares the same static member variable public staticvoid Main (string[] args) { int m = 0; Local variables, which are variables defined inside the method, are visible only within the method, and are automatically reclaimed by the garbage collector after the method finishes }}
The difference between a local variable and a global variable and a member variable in the Java Foundation