java switch

public class Main {

public static void main(String[] args){

int switchValue = 2;

switch(switchValue){

case 1:

System.out.println(“values was 1”);

break;

case 2:

System.out.println(“values was 2”);

break;

default:

System.out.println(“value was nither 1 or 2”);

break;

}

char charValue = ‘D’;

switch(charValue){

case ‘A’:

System.out.println(“values was A”);

break;

case ‘B’:

System.out.println(“values was B”);

break;

case‘C’: case ‘D’: case ‘E’:

System.out.println(charValue + ” was found”);

default:

System.out.println(“could not find A,B,C,D or E”);

break;

}

}

}

Leave a Reply

Your email address will not be published.