DEV Community

Murali Rajendran
Murali Rajendran

Posted on

Switch case

  • it is used since java version 1.0.

  • These are the primitive data types not supported in switch.

1.long
2.float
3.double
4.boolean

  • it does not accept duplicate case.

These are the primitive data types supported in switch.

1.int
2.char
3.short
4.byte

@ switch case used minimal code using arrow version 14 and above this .when we use arrow no need to use break .

arrow symbol

int tamil = 50;
switch(tamil)//Expression
{
case 50 -> System.out.println("A Grade");
case 60 -> System.out.println("b Grade");
case 100 -> System.out.println("O Grade");
default -> System.out.println("No Grade");
};

Top comments (0)