空指针异常java索引比较

时间:2015-09-18 20:46:18

标签: java pointers exception null

public int getPos(int index) {
    if(this.hasAllTerms == false){
        throw new IllegalArgumentException("Not all terms are present");
    }
    else if(index < 0 || index > terms.size()){
        throw new ArrayIndexOutOfBoundsException("Index out of bounds!");
    }

    return minSnip.get(minSnipIndex)[index+1];
  }

}

在else if行我的Junit测试失败并且说空指针异常。空指针在哪里?

0 个答案:

没有答案