Unreachable code error vs. dead code warning in Java under Eclipse?

后端 未结 8 1471
眼角桃花
眼角桃花 2020-11-28 06:59

Does anyone know why:

public void foo()
{
    System.out.println(\"Hello\");
    return;
    System.out.println(\"World!\");
}

Would be rep

8条回答
  •  情书的邮戳
    2020-11-28 07:26

    If you wish to ignore the warning "dead code warning in Java under Eclipse" do the following inside eclipse*:

    1. Click Window-Preferences-Java-Compiler-Errors/Warnings
    2. Click on "Potential Programming Problems"
    3. Choose "Ignore" the "Dead Code eg if(false)"
    4. Click Apply
    5. Click OK

    Save and close your eclipse IDE When you reopen eclipse, these specific warnings should no longer be listed.

    *For this example solution I'm using Eclipse IDE for Java Developers - Version: Mars.2 Release (4.5.2)

提交回复
热议问题