title: "cannot be resolved to a variable" in for loop
body: <p>I am new to Java. I am trying to find the factorial of a number using <code>Scanner</code>. I am getting an error at <code>p</code> as <code>p</code> cannot be  resolved to a variable. What does it mean?</p>
  
  <pre><code>import java.util.Scanner;
  
  public class fact {
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          Scanner object = new Scanner(System.in);
          System.out.println("enter a number:\n");
          int i = object.nextInt();
  
          int result = 1;
  
          for (p = 1; p &lt;= i; p++) {
              result = result * 1;
              System.out.println("factorial of a number is:result");
          }
  
      }
  
  }
  </code></pre>