Switch Case In Java

switch case statements in javaDear Students, aaj ke is Lecture me hum switch case in java ke bare main padege. Yani ke java language mian switch case kya hote hai. Java language mian switch case kaise kaam karte hai. Types of conditional statements in java aadi se related ye sare topic ham switch case in java ke lecture main cover karege.

Lectures Covering Topics

  • Introduction To Switch Case In Java In Hindi
  • What Is Use Switch Case In Java In Hindi
  • Rules For Switch Case Statement In Java Language
  • Points To Be Remember Switch Case In Java
  • What Is Syntax Of Switch Case In Java In Hindi
  • Flow Chart Of Switch Case In Java In Hindi
  • Example Of Switch Case In Java In Hindi
  • How To Work Switch Case In Java Language In Hindi

Switch case in java statements Control statements ka he part hai. Control statements yani ki ese statements jo poore program ko control karte hai. Jab programmer user ke input par depend hota hai tab programmer control statements ka use karta hai.

Introduction To Switch Case In Java – Switch Case Kya hote hai In Hindi 

To students isse previous lecture me mene aapko if statements ke bare me bataya tha. Theekh usi tarah se switch case in java bhi work karta hai. Switch case in java statements ko samjhna bahut he simple hai. Jaise ke mene aapko bataya hai ki program ko control karne ke liye switch case statements ka use karte hai.

Java language main agar kisi statement ka use kisi condition ke base par kiya jata hai. Tab java switch case statements ka use kiya jata hai. Switch case ko conditional statement bhi kahte hai.

Dekho jab hame sirf eak ya kuch limited condition deni hoti hai. To ham if else if statements ka use kar lete hai. But jab hame bahut sari condition eak he statements me apply karni hoti hai to hum java main switch case statements ka use karte hai.

What Is Use Switch Case In Java In Hindi

Jab hum program me eak sath bahut sare if condition ka use karte hai. To program kafee bada or lengthy ho jata hai. Is bajah se program padna or samjhna kafee mushkil ho jata hai. Is problem se bachne ke liye hum switch case statements in java ka use karte hai.

To Jab hame eak se jayada condition ko eak sath apply karna hota hai. Tab ham switch case statements ka use karte hai. Jis tarah se if condition eak tow way condition statements hai. Usi tarah switch eak multi way condition statements hai.

Yah bilkul if else if else ki tarah se kaam karta hai. Hum isme eak expression ke sath bahut sare values ko eak sath compare kara sakte hai. Isme sare values case ke roop me compare karne ke liye define ke jati hai.

Rules for Switch Case In Java language

  • Switch expression hamesha integer ya character data type ki he honi chahiye.
  • Case main hamesa character or integer ki value constant honi chahiye.
  • Case ke value ko keval switch statements ke andar he use kiya ja sakta hai.
  • Switch case in java mian breakstatements use krna jaroori nahi hota hai. Yah optional hota hai. Yadi switch case main koi statements nahi milta hai. To sare cases case value se match hone ke bad bhi execute hote hai. Ise java language mian switch case ka fall through statement mana jata hai.

Points To Be Remember Switch Case In Java

Students main aapko kuch eaise points bta rha hun. Joki switch case statements ko use karne ke liye bahut he important hai.

  • Switch case statements ke liye Numbers of case values ho sakti hai.
  • Case ke values hamesha switch expression type ke honi chahiye. Case ke value literal’s ya constants honi chahiye isme variable allows nahi kiye jate hai.
  • Yad rahe case ki value unique honi chahiye. Duplicate value hone par compiler run time error generate karta hai.
  • Java switch case expression byte, short, int, long (with its Wrapper type), enums and string type ki honi chahiye.
  • Case value main eak default maan ho sakta hai. Joki optional hota hai.
  • Sabhi case statements main break statements ho sakta hai. Break statements optional hota hai.

What Is Syntax of Switch Case In Java In Hindi

Java ke Switch case statements ka syntax neeche likha hua hai.

Flow Chart Of Switch Case In Java In Hindi

Aap switch case statements ko neeche flow chart ke help se bhi samjh sakte hai. Yahn par poora eak switch case statements ka flow chart banaya gya hai.

java switch case flow chart in hindi

Example Of Switch Case In Java In Hindi

Yahn par aap switch case ko eak example ko lekar bhi samjh sakte hai. neeche likhe huye example ko aap pane compiler par type karke run kara sakte hai.

First simple Example of Switch case statements in java

Output 

switch case statements in java in hindi 1

Second Example of switch case in java find the month name 

Output 

switch case statements in java in hindi 2

Example of Java Switch Case Statement with String

Output

switch case statements in java in hindi 3

How To Work Switch Case In Java Language In Hindi

Switch case statements ke execution ke liye sabse pahle variable ya expression ki value ke tulna (compare) eak eak karke sabhe cases ke ki jati hai. Or jhan bhi value mil jati hai uske statements ko execute kiya jata hai. Sabhi statements ke bad agr break statement lga hota hai to switch ko vahi break kar diya jata hai.

Yadi break statement nahi likha hota hai to value milne ke bad sabhi cases execute hote hai.  Jab tak switch case ko break statements nahi mil jat hai tab tak vah apne sare statement execute karta hai.

Switch case statements main di gayi default case label eak optional label hai. Yadi yah switch statements main hot hai. Or expression ya variable main diye gaye maan (value) switch statements me diye gaye kisi bhi case statements se match nahi karti hai. To Program control default case label ko execute karta hai. Jab tak ise bhi koi break statements nahi milta to ye bhi apne sabhi statements execute karta hai.

Related Lecture

Dear Students, main aasha karta hun ki aapko switch case in java Ka Lecture padh kar samjh me aa gaya hoga. Ki java language main switch case ka use kaise karte hai. Yadi aapako (switch case in java) 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 *