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!
Nesta página do site você pode assistir ao vídeo on-line Understand Switch Case Statements in Java tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário K. V. Siva Surya 28 Junho 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 37 vezes e gostou 2 espectadores. Boa visualização!