About Question enthuware.ocpjp.v17.2.3708 :
Posted: Thu Oct 31, 2024 11:05 am
hi,
regarding the second answer:
switch(x){
case 2 -> {
System.out.print("A");
break; //redundant but allowed
}
case 3 -> System.out.print("B");
//break; //break not allowed here
default -> System.out.print("C"); //default is not necessary in a switch statement
}
Where it says "//redundant but allowed", shouldn't there be a yield statement as its in {}? I am thinking specifically with java 17 only.
Thanks
regarding the second answer:
switch(x){
case 2 -> {
System.out.print("A");
break; //redundant but allowed
}
case 3 -> System.out.print("B");
//break; //break not allowed here
default -> System.out.print("C"); //default is not necessary in a switch statement
}
Where it says "//redundant but allowed", shouldn't there be a yield statement as its in {}? I am thinking specifically with java 17 only.
Thanks