title: How to create a static array that has a length defined by user input?
body: <p>I have a program where a number of grades are entered by the user and stored into array which is then used by the program to calculate various values.</p>
  
  <p>I'm using multiple methods so I want to define a static array that all the methods can refer to and will hold the grades. However I want its length to be equal to the number of grades entered.</p>
  
  <pre><code>public class GradeStatistics {
  static int numGrades, sum = 0;
  static int[] grades = new int[numGrades];
  
  public static void main(String args[]){
      readGrades();
      calcSum();
  </code></pre>
  
  <p>the <code>readGrades()</code> method finds out how many grades there will be and assigns it to numGrades</p>
  
  <pre><code>public static void readGrades(){
      Scanner input = new Scanner(System.in);
  
      System.out.print("Enter the number of grades: ");
      numGrades = input.nextInt();
  </code></pre>
  
  <p>Is there a way I can get the user to enter the number of grades before defining the static array?</p>