title: Calling a method to create an array in another class
body: <p><strong>StudentDemo:</strong></p>
  
  <pre><code>public class studentDemo {
      public static void main(String[] args) throws IOException{
          int runit = 0;
  
          StudentMenu run = new StudentMenu();
          while (runit != 1) {
              run.menu();
          }
      }
  }
  </code></pre>
  
  <p><strong>StudentMenu:</strong></p>
  
  <pre><code>public class StudentMenu {
  
      public Student func = new Student();
      List&lt;Student&gt; studentList = new ArrayList&lt;Student&gt;();
  
      String input;
      String input2;
      String input3;
  
      public void menu(){
          System.out.println("Choose an option: ");
          System.out.println("1) Add a student ");
          System.out.println("2) Display student list ");
          System.out.println("3) Exit ");
  
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          try {
  
              input = br.readLine();
              int choice = Integer.parseInt(input);
              System.out.println("Choice: " + choice);
  
              if(choice == 1){
                  System.out.println("First name: ");
                  input = br.readLine();
                  System.out.println("Last name: ");
                  input2 = br.readLine();
                  System.out.println("Number of classes to add for student: ");
                  input3 = br.readLine();
                  int numberOfClasses = Integer.parseInt(input3);
  
                  studentList.add(new Student(input, input2, numberOfClasses));
  
                  func.createClassList(numberOfClasses);
              }
  
              if(choice == 2){
              }
  
              if(choice == 3){
                  System.exit(0);
              }       
          }
          catch (IOException ioe){ 
              System.out.println("An unexpected error occured.");
          }
      }
  }
  </code></pre>
  
  <p><strong>Student:</strong></p>
  
  <pre><code>public class Student{   
  
      private String firstName;
      private String lastName;
      private int classes;
      //Create array for classes
      private String[] classesList = new String[classes];
  
      public Student(){
          firstName = "no name";
          lastName = "no name";
          classes = 0;
      }
  
      //overloaded constructor
      public Student(String theFirstName, String theLastName, int theClasses){
  
          firstName = theFirstName;
          lastName = theLastName;
          classes = theClasses;
          System.out.println("Number of Classes: " + classes);
      }
  
      //Populating array
      public void createClassList(int classes){
  
          //Call array method
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          try{    
              for(int i = 0; i &lt; classes; i++){
                  System.out.println("Number of Classes: " + classes);
                  System.out.println("Enter class " + i + ":");
                  String input = br.readLine();
                  classesList[i] = input;
              }
          }
          catch (IOException ioe) { 
              System.out.println("An unexpected error occured.");
          }
      }
  
      //Getters
      public String getFirstName(){ return firstName; }
  
      public String getLasName(){ return lastName; }
  
      public int getNumberOfClasses(){ return classes; }
  
      //Setters
      public void setFirstName(String newFirstName){
          firstName = newFirstName;
      }
  
      public void setLastName(String newLastName){
          firstName = newLastName;
      }
  
      public void setNumberOfClasses(int newNumberOfClasses){
          classes = newNumberOfClasses;
      }
  }
  </code></pre>
  
  <p>Sorry if I pasted this in a little bit incorrectly.</p>
  
  <p>I am trying to create a program the builds a list of students with their first name, last name, and list of classes. However, I keep running into this error after entering the first class:</p>
  
  <pre><code>ABRT problem creation: 'success'
  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
  at Student.createClassList(Student.java:37)
  at StudentMenu.menu(StudentMenu.java:37)
  at studentDemo.main(studentDemo.java:10)
  </code></pre>
  
  <p>And here is the output before the error:</p>
  
  <pre><code>Choose an option: 
  1) Add a student 
  2) Display student list 
  3) Exit 
  1
  Choice: 1
  First name: 
  t
  Last name: 
  s
  Number of classes to add for student: 
  3
  Enter class 0:
  eng
  </code></pre>
  
  <p>Right after typing eng, the error comes up.<br>
  There shouldn't be an OutOfBoundsException from what I can tell, as 3 is the limit of the index and I only typed in one class.</p>
  
  <p>Any help would be greatly appreciated, thank you!</p>