title: Adding an ArrayList into a class - what does it do?
body: <p>Following on from this Q of mine: <a href="https://stackoverflow.com/questions/754184/whats-the-best-way-to-make-this-java-program">What&#39;s the best way to make this Java program?</a></p>
  
  <p>I was recommended to store a list in Lecturer class and Course class. So I did, and it looks something like this:</p>
  
  <pre><code>public class Lecturer
  {
      private String id;  
      private String name;  
      List&lt;Course&gt; courses = new ArrayList&lt;Course&gt;();  // a list to hold the courses
  
  
      public Lecturer(String idIn, String nameIn)     // arguments of the constructor
      {
          id = idIn;
          name = nameIn;
  
      }
  
  }
  </code></pre>
  
  <p>Same thing for the Course class except it has Lecturer list. But what I dont get is what does placing a list there exactly do? cos I dont know where to put the methods of the ArrayList such as adding and removing lecturers from it?</p>
  
  <p>Can someone explain the purpose of this?</p>
  
  <p>I use another method which is basically placing the arraylists and its methods in two seperate classes for the lecturer and course, and then I simply add into the Course and Lecturer class as an attribute eg:</p>
  
  <pre><code>public class Lecturer
  {
      private String id;  
      private String name;  
      private CourseList courses;  // COurseList is the class with the arraylist and methods
  
  
      public Lecturer(String idIn, String nameIn)     // arguments of the constructor
      {
          id = idIn;
          name = nameIn;
          courses = new CourseList();
      }
  
  }
  </code></pre>
  
  <p>I hope i'm making sense, cos ive been stuck on one thing for the last 2 weeks which no seems to understand.</p>
  
  <p>Thank you</p>