Java Variables in hindi | (जावा वेरिएबल्स क्या है)

 

Java Variables in hindi | (जावा वेरिएबल्स क्या है)

नमस्कार दोस्तो आज इस Article में जानेंगे Java Variables in hindi | (जावा वेरिएबल्स क्या है) / जावा Variables कितने प्रकार के हैं ?

Introduction of Java Variables :

Variables ये memory locations के नाम होते है | जो values; variables को दी जाती हैं, वो उस location पर store हो जाती है |

Syntax for Variables Declaration :

1
2
data_type_name variable_name; //or
data_type_name variable_name1, variable_name2;

Example :


1
2
int a;
int b, c;


Syntax for Variables Definition :

1
data_type variable_name = variable_value;

Example :

1
2
int a = 5;
int b = 10, c = 15;

Type of Variables : Java Variables कितने प्रकार के होते हैं /

Java के लिए Variables के तीन प्रकार होते हैं |

  1. Local Variable
  2. Instance Variable
  3. Static Variable

Local Variables : Java local variables in hindi

Local Variables block, methods और constructor के अन्दर होते है |

Local Variable का scope; local होता है | ये सिर्फ methods और constructor के अन्दर visible होते है |

जब Local Variables; methods और constructor के बाहर जाते है, तब destroyed हो जाते है |


Source Code :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Sample{
    
   void display(){
       int a = 5;   //Local Variable
       System.out.println("Value of a : " + a);
    }
    public static void main(String arg[]){
        Sample s = new Sample();
        s.display();
    }
}


Output : 

1
Value of a : 5

Instance Variable : Java instance variable in hindi

Instance Variables; class के अन्दर होते है और methods और constructor के बाहर होते है |

Instance Variables non-static variables होते है |

Source Code :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class Sample{
    int a = 5;  //Instance Variable
   void display(){
       System.out.println("Value of a : " + a);
    }
    public static void main(String arg[]){
        Sample s = new Sample();
        s.display();
    }
}


Output :

1
Value of a : 5

Static Variable : Java static variable in hindi

Static Variables को Class Variables भी कहते है |

ये Instance Variable के तरह class के अन्दर और methods और constructor के बाहर होते है |

'static' keyword के साथ इनका इस्तेमाल किया जाता है |


Source Code :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class Sample{
    static int a = 5;  //Static Variable
   void display(){
       System.out.println("Value of a : " + a);
    }
    public static void main(String arg[]){
        Sample s = new Sample();
        s.display();
    }
}


Output :

1
Value of a : 5




अगर आपको यह पोस्ट 📑 पसंद आई हो तो अपने मित्रों के साथ जरूर शेयर करें। धन्यवाद !
Maxon

Hello there! I'm Maxon, a dedicated UI/UX designer on a mission to transform digital experiences into intuitive, user-centric journeys. With a keen eye for detail and a passion for crafting aesthetically pleasing interfaces, I strive to create designs that not only look stunning but also enhance usability and functionality.

Post a Comment

Previous Post Next Post