简体   繁体   English

Eclipse将行标记为死代码

[英]Eclipse marks lines as dead code

I have this function with some dead code, marked by Eclipse. 我有这个函数,有一些死的代码,由Eclipse标记。

I have two lines that check a & b. 我有两行检查a&b。 Lines that check b are marked as null. 检查b的行标记为空。

    public int[] runThis(List<Integer> buildIds, List<Integer> scenarios, boolean oflag) {

    int rating[] = new int[scenarios.size()];

    if(buildIds == null) {
        System.out.println("ERROR - Building ID list is null!");
        return null;
    }

    if(scenarios == null) {
        System.out.println("ERROR - Scenario list is null!"); //dead
        return null; //dead
    }

    return rating;      

}

Why does Ellipse make the two lines as dead? 为什么Ellipse让这两条线死了? Any help? 有帮助吗? Thanks very much for your time. 非常感谢你花时间陪伴。

Because you've already called scenarios.size() in your array constructor. 因为您已经在数组构造函数中调用了scenarios.size() This guarantees scenarios isn't null or it will have thrown an exception by that point. 这保证scenarios不为null,或者它将在该点抛出异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM