Unreachable code in eclipse

The first message, Exception in thread "main" java.lang.Error: Unresolved compilation problem:means your code does not compile. You need to identify the error and fix it. Modern IDEs e.g. Eclipse, Netbeans, etc flag compile errors. They can help you to quickly identify the source.

The second error:

Unreachable Code
at mycode.sample.main(sample.java:24

means that the code at line 24 will never be reached.

Here is an example of unreachable code:

public void doSomething() {
    if (true) {
        return;
    }
    // All code below here is considered unreachable code
    doSomething()
}

Leave a Comment