tags:

views:

88

answers:

1

I'm getting a dead code error in this Java code snippet, using 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++;
        }
}
+7  A: 

The if statement only checks final static values from the Equipment class and the compiler detects, that this condition can never be true so the following lines are dead code (unreachable).

Andreas_D