title: Insert Object into Java Array
body: <p>I got from my teacher the next assignment -</p>
  
  <p>I need to build a <code>Course</code> class and <code>Student</code> class
  and to insert every Student into the Course class
  Each Student has an Id,name and grade.</p>
  
  <p>I have tried the next code:</p>
  
  <pre><code> public class Course {
  
      Student[] android = new Student[100];
  
  
      private void addStudent(Student a) {
          for (int i=0;i&lt;android.length;i++) {
              if (android[i] == null) {
                  android[i] = a;
                  break;
              }
          }
  
      }
  
      public static void main(String[] args) {
          addStudent(Joe);
  
      }
  
  }
  </code></pre>
  
  <p>I need to insert a Student that i have created in the Students class to the first null position in the array.
  When i try <code>addStudent(Joe);</code> it gives me an error : <em>"Joe cannot be resolved to a variable"</em></p>
  
  <p>The Student class code:</p>
  
  <pre><code>    public class Student {
  
  
                  private float grade;
                  private String name;
                  private long id;
             public Student(long c,String b,float a) {
                 grade = a;
                 name = b;
                 id = c;
             }
               public static void main(String[] args) {
               Student Joe = new Student(1,"Joe",40);
  }
  </code></pre>
  
  <p>**The array holds 100 students (null at start)</p>
  
  <ul>
  <li><p>When adding a student - i need to check for the first null value in the array and put it 
  there</p></li>
  <li><p>When printing the students: i need to print only the non-null Objects in the array**</p></li>
  </ul>