title: How to add a Course object to an array via an addCourse() method
body: <p>I am having issues with objects and classes. </p>
  
  <p>I had to define two classes: </p>
  
  <ul>
  <li><code>Course</code>: a course has a code, an name and a number of credits</li>
  <li><code>Teacher</code>: a teacher has a first name and last name. He can be asked his full  name.</li>
  </ul>
  
  <p>So far so good, I got no issue with them, but I have to do next assignment which I was trying to do in the last 2 days and I could not find a proper answer:</p>
  
  <blockquote>
    <p>Extend the code of the class teacher. A teacher also has a list of courses he can teach. Add an array of Courses to the code. Also add a function <code>addCourse(Course aCourse)</code> to the code. Courses can also be removed from teachers.</p>
  </blockquote>
  
  <p>I could do everyting in my way but no clue on how to create the <code>addCourse(Course aCourse)</code> method.</p>
  
  <p>Find below my coding, but it must be according to the method described:</p>
  
  <pre><code>public class Course {
  
      private String courseCode;
      private String courseName;
      private String numberOfCredits;
  
      public Course(String courseCode, String courseName, String numberOfCredits) {
          super();
          this.courseCode = courseCode;
          this.courseName = courseName;
          this.numberOfCredits = numberOfCredits;
      }
  
      public void print() {
          System.out.println(courseCode + "\t" + courseName + "\t" + numberOfCredits);
      }
  
      public static void main(String[] args) {
  
          Course[] courseArray = new Course[4];
  
          System.out.println("Code" + "\t" + "Name" + "\t" + "Credits");
  
          courseArray[0] = new Course("001", "Hist", "3");
          courseArray[1] = new Course("002", "Phy", "3");
          courseArray[2] = new Course("003", "Math", "3");
          courseArray[3] = new Course("004", "Log", "3");
  
          for (int i = 0; i &lt; courseArray.length; i++) {
              courseArray[i].print();
          }
  
      }
  }
  </code></pre>