title: Why can I not set an integer equal to another integer inside a for loop?
body: <p>I currently have the code as follows, its function is explained below:</p>
  
  <pre><code>import java.util.Scanner;
  class Main
  {
  
      public static void main(String[] args) 
      {
      Scanner Kb = new Scanner(System.in);
      int spacesLn = 0;
      int numSaver = 0;
      int numAst;
  
      System.out.println("Enter The Number of Asterics You Would Like To Create");
      numAst = Kb.nextInt();
  
  
      for(int Spaces = 0; Spaces &lt;= numAst; Spaces++)
      {
          while(spacesLn &lt; 0)
          {
              System.out.print(" ");
              spacesLn++;
  
          }
          numSaver--;
          spacesLn = numSaver;
          System.out.print("*");
          System.out.println("");
      }   
    }
  }
  </code></pre>
  
  <p>This program asks for a number then makes a diagonal line of asterisks equal to that number in the following fashion: line one - zero spaces, followed by an asterisk, line two - one space, followed by an asterisk, etc. Strictly speaking the function of the code is slightly irrelevant to my question, but there it is anyways. It works perfectly. Despite this, I decided that I wanted to make the while loop that is nested in the for loop, into a for loop. I changed the code containing the loops to as follows, and I deleted the declaration of the variable spacesLn.</p>
  
  <pre><code>for(int Spaces = 0; Spaces &lt;= numAst; Spaces++)
      {
          for(int spacesLn = 0; spacesLn &lt; 0; spacesLn++)
          {
              System.out.print(" ");
          }
          numSaver--;
          spacesLn = numSaver;
          System.out.print("*");
          System.out.println("");
  
      }
  </code></pre>
  
  <p>Now when I run this it gives me this error:</p>
  
  <pre><code>Main.java:21: error: cannot find symbol
              spacesLn = numSaver;
              ^
    symbol:   variable spacesLn
    location: class Main
  1 error
  
  exit status 1
  </code></pre>
  
  <p>I'm very confused by this error, I cannot seem to figure out what I am doing incorrectly. Although I can assume that my error will be inevitably stupid on my part I just feel like I've dotted my "i"s and crossed my "t"s. </p>
  
  <p>Please if anyone could help me understand my error I would be extremely grateful. Many thanks in advance, Max.</p>