java.lang.ArrayIndexOutOfBoundsException: 0 when adding to array
<p>When I run program(in java) I get this error :</p>

<pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at Course.addStudent(Course.java:31)
    at TestProgram.main(TestProgram.java:22)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconenter code hereds) 



 public boolean addStudent(Student student){

     if(numberOfStudents &lt; capacity) {
             int k = 0;
***[MISTAKE]*** this.student[numberOfStudents] = student;***[MISTAKE]***

                numberOfStudents++;
            return true;
        }
        else return false;
    }
</code></pre>

<p>What can I do to solute this problem ? I am dealing with Student,Personal data, course objects. Here , I want to add student. there is no problem if I don't run program.
 NetBeans doesn't show any problem when I write. But when I run program, It shows a mistake.</p>
