VARIABLES AND DATA TYPES IN JAVA

Variable is a name of memory location. There are three types of variables in java: local, instance
and static.
There are two types of data types in java: primitive and non-primitive.
*TYPES OF VARIABLE 
There are three types of variables in java:
o local variable
o instance variable
o static variable
 1)LOCAL VARIABLE
A variable which is declared inside the method is called local variable.
2) INSTANCE VARIABLE
A variable which is declared inside the class but outside the method, is called instance variable . 
It is not declared as static.
3) STATIC VARIABLE
A variable that is declared as static is called static variable. It cannot be local.

EXAMPLE TO UNDERSTAND THE TYPES OF VARIABLES IN JAVA

class A{ 
int data=50;//instance variable
static int m=100;//static variable
void method(){
int n=90;//local variable
}
}//end of class

Posted on by