Programming Code Examples

Variables In Java Example1 min read

Java Code:

Variable is a name of memory location that can contain a data value.




A variable has a data type.

There are three types of variables in java: local, instance and static.

Local Variable : A variable which is declared inside the method is called local variable.

Instance Variable : A variable which is declared inside the class but outside the method, is called instance variable .

Static variable : A variable that is declared as static is called static variable. Memory allocation for such variables only happens once when the class is loaded in the memory.

Add comment