Switch-case is used by devolopers for defining to computer conditional statements. Switch-case expressions have same functions with if blocks.Using of switch case use less common than if blocks wherefore if blocks are more useful in projects of software.
Structere of Switch-case;
switch( parameter){
case x:
......// if parater is x, these codes are run that untill break expression.Does not run any other statement break's below.
break;
case a:
......// if parater is a, these codes are run that untill break expression.Does not run any other statement break's below.
break;
}
public class Main {public static void main(String[] args) {
int BestTeam=6;
switch(BestTeam){
case 1:
System.out.println("Best Team in Spain is Barcelona");
break;
case 2:
System.out.println("Best Team in İtaly is Juventus");
break;
case 3:
System.out.println("Best Team in England is Liverpool");
break;
case 4:
System.out.println("Best Team in France is PSG");
break;
case 5:
System.out.println("Best team in Netharlands is Ajax");
break;
case 6:
System.out.println("Best Team in Turkey is Trabzonspor");
break;
default:
System.out.println("please choose number for 1-6");
}
}
}OUTPUT:Best Team in Turkey is Trabzonspor
Comments
Post a Comment