Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse marks lines as dead code

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.

like image 752
jn1kk Avatar asked Nov 07 '11 16:11

jn1kk


1 Answers

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.

like image 190
BenCole Avatar answered Oct 06 '22 05:10

BenCole