Some help me with 10/11


#1


I like to know in wich case would the "default" option print to the console ---> System.out.println("Messi is in position..."); <---


public class Switch {
	public static void main(String[] args) {
		
		char penaltyKick = 'L';

		switch (penaltyKick) {

			case 'L': System.out.println("Messi shoots to the left and scores!");
								break; 
			case 'R': System.out.println("Messi shoots to the right and misses the goal!");
								break;
			case 'C': System.out.println("Messi shoots down the center, but the keeper blocks it!");
								break;
        
			default:
				System.out.println("Messi is in position...");
        break;

		}


#2

The default will execute when all of the above cases are not met.

i.e. In this example, if penaltyKick is not equal to either 'L', 'R', 'C', then the default will produce "Messi is in position...".


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.