Variables in Java

Variables:-
1)  A variable is a value that can be change
2) Variable is a container that holds the  values while Java program is executed
3) Their are 3 types of Variables :-

‌Local Variables :-  Local variables is declare in inside body of the method. 


‌Instance Variables :- Instance variables is declare in inside the class but outside the method


‌Static variables:- A variable that can be declare with Static is called static variables


Example:-
class A   //Class declaration
{
static int a=10 ;    //Static variable
void method
{
int b=20 ;     //Instance variable
}
public static void main(String args [])
{
int c=30 ;      //Local variable
}
}

Comments

Popular posts from this blog

ChatGPT-3