Switch statement with returns -- code correctness
I would take a different tack entirely. Don't RETURN in the middle of the method/function. Instead, just put the return value in a local variable and send it at the end.
Personally, I find the following to be more readable:
String result = "";
switch (something) {
case 0:
result = "blah";
break;
case 1:
result = "foo";
break;
}
return result;
Remove the break
statements. They aren't needed and perhaps some compilers will issue "Unreachable code" warnings.