문제

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