8
我有一些由Eclipse標記的死代碼的功能。Eclipse將行標記爲死代碼
我有兩行檢查& 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會使兩條線死死?任何幫助?非常感謝你花時間陪伴。
該方法中是否有其他代碼?也許你之前解除了'b'的引用,這告訴Eclipse在這一點上'b'不能是'null'。在這種情況下,你還應該在'if(b == null)'行中得到一個類似「不必要的空值檢查」的警告。 –
@Joachim +1000。 –
我不太瞭解Eclipse *,但IntelliJ IDEA可以實時分析您的代碼,並警告您某些代碼無法實現。在你的情況下,如果IntelliJ檢測到* b *從來沒有* null *,那麼它會警告你,這兩行永遠不會被達到,因爲條件* b == null **總是爲false。 – TacticalCoder