switch (expression) {
case value1:
statement 1;
break;
case value2:
statement 2;
break;
case valueN:
statementN;
break;
default;
statement default;
}
contoh coding menggunakan swicth - case
sekian penjelasan soal switch - case,.. :D
class praktek2
{
public static void main (String args [])
{
int nilai;
nilai=6;
System.out.println("===================");
System.out.println("Nama : Helena Peacecraft ");
System.out.println("Nilai : " + nilai );
switch (nilai) {
case 10:
case 9 : System.out.println("Ket : Istimewa");
break;
case 8 :
case 7 : System.out.println("Ket : Bagoess");
break;
case 6 : System.out.println("Ket : Cukup");
break;
default;
System.out.println("Ket : Kurang");
}
System.out.println("===================");
}
}