Variables In Java
Java Variables:
● Variables in java are used to Store the data while the java
program is executed.
● A variable is assigned with a data [Link] is a name
of memory location.
● A variable is the name of a reserved area allocated in
memory. In other words, it is the name of the memory
location.
There are three types of variables in java:
● Local variable.
● Instance variable.
● Static variable.
1) Local Variable:
A variable declared inside the body of the method is called a
local variable. You can use this variable only within that
method.
Note:A local variable cannot be defined with the "static"
keyword.
2) Instance Variable:
A variable declared inside the class but outside the body of the
method, is called an instance variable. It is not declared as
static.
3) Static variable:
A variable that is declared as static is called a static variable. It
cannot be local.