title: Variable out of Range
body: <p>I have an error where line 61 states that variable <code>firstbattlerealactualhealth</code> is out of range to be used. I've tried various things, but I just can't seem to get it to work.</p>
  
  <p>If you could show me what's wrong, and what I need to fix it, I'd be grateful. </p>
  
  <p><strong>Edit:</strong> changed which variable and line had a problem because I can't count or read.</p>
  
  <pre><code>boolean firstbattle = true;
  while (firstbattle) {
      int firstbattlehealth = HP;
      int firstbattleattack = Attack;
      int firstbattledefense = Defense;
      int firstbattleMP = MP;
      int firstbattleEXP = EXP;
      int firstbattlegold = Gold;
  
      int firstattack = (int) Math.ceil(Math.random() * 6);
      int firstdefense = (int) Math.ceil(Math.random() * 6);
  
      int firstenemyattack = (int) Math.ceil(Math.random() * 6);
      int firstenemydefense = (int) Math.ceil(Math.random() * 6);
  
      int firstenemyhealth = firstenemyfirsthealth;
  
      int firstenemynewhealth = firstenemyfirsthealth;
  
      int firstenemyhitpoints = (int) Math.ceil(Math.random() * 25);
  
      int firsthitpoints = 0;
      boolean firstkill = true;
      while (firstkill) {
          if (firstattack &gt; firstenemydefense) {
              firsthitpoints = (int) Math.ceil(Math.random() * firstbattleattack);
              System.out.println();
              System.out.println("You did " + firsthitpoints + " damge to the Slime.");           
          }
  
          firstenemynewhealth = firstenemyhealth - firsthitpoints;
  
          if (firstenemynewhealth &lt;= 0) {
             firstkill = false;
          }
  
          if (firstattack &lt;= firstenemydefense) {
              System.out.println();
              System.out.println("Attack failed!");
          }
          int firstbattleactualhealth = firstbattlehealth;
          if (firstenemyattack &gt; firstdefense) {
              int firstenemyhitpointattack = (int) Math.ceil(Math.random() * firstenemyhitpoints);
              int firstbattlerealactualhealth = firstbattleactualhealth - firstenemyhitpointattack;
              System.out.println();
              System.out.println("The enemy did " + firstenemyhitpointattack + " damage to you. You have " + firstbattlerealactualhealth + " health remaining.");
          }
  
          if (firstenemyattack &lt;= firstdefense ) {
              System.out.println();
              System.out.println("Enemy attack missed!");
          }
      }
  
      int firstenemyactualhealth = firstenemynewhealth;
      if (firstenemyactualhealth &lt;= 0){
          System.out.println();
          System.out.println("You won the battle!");
  
          HP = firstbattlerealactualhealth;
          EXP =  firstbattleEXP + 20;
          Gold = firstbattlegold + 20;
          System.out.println();
          System.out.println("You have " + HP + " health.");
          System.out.println("You have earned" + EXP + " experience.");
          System.out.println("You have earned" + Gold + " gold.");
  
          firstbattle = false;
      }
  }
  </code></pre>