Quiz · Conditions · lesson 8 of 8
Quiz — a switch expression without default
What happens when the program is compiled and run?
public class Main {
public static void main(String[] args) {
int n = 3;
String s = switch (n) {
case 1 -> "one";
case 2 -> "two";
};
System.out.println(s);
}
}