Monday, 17 April 2017

Types of variables in java


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:
class A{
int data=50;//instance variable
static int m=100;//static variable
void method(){
int n=90;//local variable
}
}//end of class

No comments:

Post a Comment