- Local variables are declared in methods, constructors, or blocks.
- Local variables are visible only within the declared method, constructor or block.
- Instance variables are declared in a class, but outside a method, constructor or any block.
- The instance variables are visible for all methods, constructors and block in the class.
Class / Static variables
- Class variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block.
- Visibility is similar to instance variables. However, most static variables are declared public since they must be available for users of the class.
- Static variables can be accessed by calling with the class nameClassName.VariableName.