the following is java code:
switch (num) {
case 13:
System.out.println("yay! num is thirteen!");
case 27:
System.out.println("num==twenty-seven!");
default:
System.out.println("what a boring number");
}
the syntax is correct. Given a proper program body, it will compile and run. However, there is still a bug in the code. What's the logic bug? Why would the java allow this to compile? What is a use case for this language feature?
Subscribe to:
Post Comments (Atom)
1 comment:
missing the "break"'s in each case. thus, we'll actually print everything. this is useful in cases where we want to execute some code that overlaps for different cases
Post a Comment