Variable
Variable is name of memory, which use to allocate reserve memory location. It is also called as "VARY+ABLE" which means vary can be changed.Here a is used to allocate memory to variable |
Types of Variable:
Local Variable: Which is initialize inside the method is called as local variable.
Instance Variable: Which is initialize inside the class but outside the method is known as Instance variable.
Static Variable: A variable which is declared as Static is known as static variable, A static variable can not be used as local variable.
Example
public class Second
{
static int a = 10;//Global Variable
static int c;// instance Variable
public static void main(String[] args)
{
int b = 20;// Local Variable
c=a+b;
System.out.println(c);
}
}
0 comments:
Post a Comment