About Question enthuware.ocpjp.v17.2.3709 :
Posted: Wed Oct 04, 2023 4:15 pm
Hi, can you please clarify why this option is considered as correct?
Every case must return a value.
if the case statement throws an exception. How this can be considered as returning value?
in this example I believe case C does not return value instead it throws an exception.
Please clarify...
Every case must return a value.
if the case statement throws an exception. How this can be considered as returning value?
Code: Select all
var a = SomeEnum.A;
String s = switch (a){
case A -> "ada";
case C -> throw new RuntimeException("qweqe");
case B -> "qwejqle";
};
Please clarify...