Java Variables

Dear Students, aaj ke is Lecture me hum janege Java Variables ke bare main yani ke java language main variables kaise define karte hai. Or sath me variables kya hote hai. Variable ke definition or types of variable aadi se related ye sare topic ham java variables ke lecture me cover karege.

Lectures Covering Topics

  • Introduction Java Variables In Hindi
  • Declaration Of Java Variables In Hindi
  • Initialization Of Java Variables In Hindi
  • Rules Of Defining Java Variables
  • Types Of Java Variables

Students yadi aap kisi data ke sath operation perform karna chahate hai. To sabse pahle aapko use computer ki memory me store karna padta hai. Computer me data ko store karne ke liye variables ka use kiya jata hai.

Students java main kisi bhi information ko store karne ke liye hame java variables ka use karna hota hai. Or us variable me store hui information ko us variable ke value kahte hai. Ye value kuch bhi ho sakti hai jaise aapka roll number, aapka naam, aapka address idyadi.

Is information me do tarah ki value milti hai jaise aapka roll number eak numeric value hai. Or apaka naam & address ek word character type value hai. Hume Different types ki value ko different type ke java variables me store karana hota hai.

Introduction Java Variables In Hindi

Different types ke information ke sath different type ke operation perform karne ke liye hum apne data ko separately store karna hota hai. Hum kisi bhi variable ki value change kar sakte hai.

Hum kabhi bhi kisi bhi variable me uski value ko change kar sakte hai. But kuch aise bhi variable hote hai jinki value change nahi ki ja sakti hai unhe ham constant kahte hai.

Kisi bhi data ya information ko store karne ke liye aapko variable ki jaroorat padti hai. variables create karne ke liye ham variable ka naam dete hai. Or variable ke naam se pahle uska data type bhi define karte hai.

Note:- (Variable ke bare me samjhne se pahle aapko data type ke bare me pta hona chahiye. Agar aapko pta hai to aap java variable lecture ko continue kar sakte hai. Agar aap data types ke bare me panda chahte hai to aap java data types ke lecture ko pad lijiye.)

What is data type in java padne ke liye click karen

Declaration Of Java Variables In Hindi

Ek Java variable create karne se pahle ham us variable ka data type define karte hai. Ye hame pata hona chahiye ki hame kis tarah ka data store karna hai.

Iske bad ham ek unique name define karege. Name number ya fir kisi symbols se start nahi hona chahiye. Jaise ki name kuch is tarah se rakh sakte hai. Value, Value1, val_name aadi. C language me variable create karne ka syntax neeche diya hua hai.

  • Without assigning value:- <data type> <variable name>;
  • With assigning value:- <data type> <variable name> = <variable value>;

Examples ke liye neeche create kiye hue variables dekh lijiyega.

  • int num;
  • int num2=10;
  • char ch;
  • char ch=”a”;

Upar diye first variable me int(number) type ka ek num name ka variable memory me create hua hoga. Joki koi bhi numeric value store kar sakta hai. According to second variable ye bhi int type ka ek num2 naam ka variable memory me create karega. Lekin iski value hamne pahle se he define kar di hai jo ki 10 hai.

Initialization Of Java Variables In Hindi

Jab ham koi variable declare karte hai. To usme ek undefined value hoti hai jise ham log garbage value ka naam de dete hai. Agar ham chahate hai ki variable ko define karne ke time par variable me koi initial value assign ho ise ham initialization of variables kahte hai.

Like example:-

Int a=6;

Float f=8.9, fl=83.3;

Char ch=’h’;

Rules Of Defining Java Variables In Hindi

Variable define karne se pahle hame kuch baton par dhyan dena bahut jaroori hai. Kyoki variable define karne ke kuch rules hote hai. Agar ham in rules ko follow nahi karte hai. To compiler hamare program me error generate karta hai. There are some rule for defining variables in c-

  • Ek variable me digits, underscore, alphabets ho sakte hai.
  • Kisi variable ko underscore, alphabets se start kar sakte hai kisi number ya digits se nahi kar sakte.
  • Kisi variable me koi bhi white space allowed nahi hai.
  • Variable ka naam koi reserved keyword nahi hona chahiye jaise int, char, float.
  • Variables ko define karne se pahle variable ka data type jaroor hona chahiye.

Types Of Java Variables In Hindi

  • Local Variable
  • Global Variable
  • Static Variable
  • Automatic Variable
  • External Variable

types of java variables 1

Local Variable

Local variables wo variables hote hai. Jo program main kisi user define function, control statement block me define kiye jate hai. Is trah ke variables ki limit sirf usi block or function me rahti hai. Or ham local variables ko usi block me use kar sakte hai.

Block yani function ki starting me he variable ko declare kiya jana chahiye.

Just Like example-

Global Variable

Global variable wo variable hote hai jinkka scope poore program me hota hai. In variables ko aap poore program me kahi bhi access kar sakte ho. In variables ko program ke starting me hi define kiya jata hai.

Agar koi bhi kisi global variable ki value change karta hai. To fir wo value poore program ke liye change ho jati hai.

For example-

Static Variable

Static variable ko declare karne ke liye hame variable se pahle static keyword use karna hota hai. Jis variable ke starting me static keyword use kiya jata hai us variable ko static variable kahte hai.

Agar ham kisi bhi function ko bar bar call karte hai to static variable ki change hui value ko use karta hai.

For example-

Yadi ham is function ko kai bar call karte hai. To local variable sabhi function ke liye same value print karta hai example 20, 20, 20. Lekin static variable sabhi function me apni value ko incremented value print karega karega jaise 21, 22, 23.

Automatic Variable

C language me kisi block ya function me declare sabhi variables by default automatic variable hote hai. Ham auto keyword ka use karke bhi kisi bhi variable ko automatic variable bana sakte hai.

Example ke liye:-

External Variable

Ham c language ki header file ka use karke external variable bhi create kar sakte hai. External keyword ko declare karne ke liye hame extern keyword ka use karna padta hai. External variable bhi global variable he hote hai.

For example-

Note:- Aap header file ke bare me next lecture me padege. To aap yhan abhi header file ka naam padkar confuse mat hona.

Related Lecture

Dear Students, main aasha karta hun ki aapko Java Variables Ka Lecture padh kar samjh me aa gaya hoga ki variables kya hai hote hai. Yadi aapako (Java Variables) ke Lecture se related koi bhi problem hai to aap hume comment karke puch skte hai.

Share This Post On

About Author

Thakur Aman Singh

Hey, I am Aman Singh Tomar from Taj City Agra. Through This Blog I want to share my Knowledge with all of you. Read More >>

Leave a Reply

Your email address will not be published. Required fields are marked *