Java Variables

Variable allocates reserved memory area.

char ch=’A’;//chis variable
int num=10;//num is variable

Types of Variable

  • Local Variable is declared inside the method.
  • Instance Variable is declared inside the class but outside the method.
  • Static variable is declared as with static keyword.


class MyVariables{  
   int num1=50;//instance variable  
   static int2 m=100;//static variable  
   void method(){  
      int num3=90;//local variable