سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top