I have a problem defining a static method in a class, see if you can help me:
public boolean checkcmd(String in, String cmd, String ... arg)
{
...
check.a(); // esta linea
...
}
class check
{
static void a()
{
...
}
}
The error I get is "Unreachable code", on the marked line.
Thank you very much!
The compiler detects that the method, at some point, is going to terminate somehow or that there is no way to continue execution, so code written after that end point will not be executed . This generates the "Unreachable code".
Examples:
Deliberately throw an exception:
Return a value, or simply return if it is a method
void
:Have an infinite loop:
There are cases where it is a bit more difficult to detect (but not impossible). Example:
That said, we need your full code to detect the unreachable code.
That the method called inside your instance method is a static method is not associated with the problem .