title: Variable is reset after loop
body: <p>I'm learning Java and have written a program with a for loop in it. But my variable is 0 after I print it out. Why does it get reset? This is my code:</p>
  
  <pre><code>Private static int number;
  
  public static void main(String[] args)
  {
      int number = 0;
      for (int i = 0; i &lt; 10; i = i + 1)
      {
          number = number + 1;
      }
      System.out.println("Main: " + number);
      print();
  }
  
  public static void print()
  {
      System.out.println("Print: " + number);
  }
  </code></pre>
  
  <p>This is the result: </p>
  
  <blockquote>
    <p>run:</p>
    
    <p>Main: 10</p>
    
    <p>Print: 0</p>
    
    <p>BUILD SUCCESSFUL (total time: 0 seconds)</p>
  </blockquote>