Switch Case statements are similar to conditionals like the if statement. They basically check the equality of a value against other values. You can do the exact same thing using conditionals by just checking if(value==anotherValue) but it is more efficient and definitely structures your code better when you use switch Case Statements.
Switch Case statements involve two main keywords- switch, and case. The video isn't going to just explain what these keywords mean but it's going to help you get an intuitive understanding about them.
I hope the video was helpful. If it was, please don't forget to like, share, and subscribe. It's free and it helps me a lot
Program:
import java.util.*;
public class Switchcase {
public static void main(String[]args){
Scanner sa=new Scanner(System.in);
System.out.println("enter 1 for pizza");
System.out.println("Enter 2 for burger");
System.out.println("Enter 3 for biryani");
int value= sa.nextInt();
switch(value){
case 1: System.out.println("Pizza!");
break;
case 2: System.out.println("burger!");
break;
}
}
}
I hope this sample program helps out!
Sur cette page du site, vous pouvez voir la vidéo en ligne Understand Switch Case Statements in Java tutorial durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur K. V. Siva Surya 28 juin 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 37 fois et il a aimé 2 téléspectateurs. Bon visionnage!