Hi ranchers,
... and welcome, Augusteen, to the
Java Ranch!!!
The compiler knows, that at runtime this method may return nothing. Would be the case if you call e.g.
f(123);
And if it isn't sure, that a String will returned in all circumstances, the code does not compile.
Better than Saheed's idea of returning a null at the very end of the method would be a
default case, perhaps returning a blank or empty String (depends on your purposes).
Yours,
Bu.