title: Use Variable Which is in main method in Another Method
body: <p>I'm trying to create a simple program to output the number of stars entered by user. I'm trying to learn how to use more than one method to do this
  Here's my code</p>
  
  <pre><code>import java.util.Scanner;
  public class Alpha 
  {
      public static void main(String args[])
      {
          Scanner input = new Scanner(System.in);
           int n;
  
          System.out.println("Enter no. of stars");
          n = input.nextInt();
  
      }
      public static void Loop ()
      {
          for (int counter = 1; counter &lt;= n; counter++)
          {
              System.out.println("*");
          }
      }
  }
  </code></pre>
  
  <p>The problem I'm facing is that in the Loop method, I am unable to use the variable n
  Is there a way to use a variable which is in the main method, in another one?
  Ty</p>
  
  <p>-Pingu</p>