2010-08-22 71 views
0

我得到一個死代碼錯誤在這個Java代碼片段,使用Eclipse:死代碼錯誤

public void rebirthAction() { 
    Player p = new Player(null); 
    Equipment e = new Equipment(); 
    Skills s = new Skills(null); 
    if ((Equipment.SLOT_SHIELD == -1) && (Equipment.SLOT_WEAPON == -1) && (Equipment.SLOT_CHEST == -1) && (Equipment.SLOT_BOTTOMS == -1) && (Equipment.SLOT_AMULET == -1) && (Equipment.SLOT_BOOTS == -1) && (Equipment.SLOT_HELM == -1) && (Equipment.SLOT_GLOVES == -1)) 
     for (int i = 0; i <= 7; i++) { 
      p.getSkills().setLevel(i, 1); 
      p.getSkills().setExperience(i, 0); 
      //updateRequired = true; 
      //appearanceUpdateRequired = true; 
      s.getTotalLevel(); 
      s.getCombatLevel(); 
      Combat.calculateMaxHit(p); 
      p.getSkills(); 
      rebirthCount++; 
     } 
} 
+2

怎麼樣? – 2010-08-22 17:52:40

+1

問題是什麼? – 2010-08-22 17:53:40

+0

請編輯您的問題,而不是張貼不是和評論的答案。 – 2010-08-22 17:54:25

回答

8

if語句只從設備類檢查的最終靜態值和編譯器檢測,這個條件永遠不可能是true所以下面的行是死代碼(無法訪問)。