Eclipse 将行标记为死代码

发布于 2024-12-14 14:59:38 字数 579 浏览 6 评论 0原文

我有这个函数,其中有一些死代码,由 Eclipse 标记。

我有两行检查 a & b.检查 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;      

}

为什么 Ellipse 使两条线成为死线?有什么帮助吗?非常感谢您抽出时间。

I have this function with some dead code, marked by Eclipse.

I have two lines that check a & b. Lines that check b are marked as null.

    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? Any help? Thanks very much for your time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

儭儭莪哋寶赑 2024-12-21 14:59:38

因为您已经在数组构造函数中调用了 scenarios.size() 。这保证了 scenarios 不为 null,否则此时它将引发异常。

Because you've already called scenarios.size() in your array constructor. This guarantees scenarios isn't null or it will have thrown an exception by that point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文