title: Best way to store collection of objects in Java?
body: <p>I am creating a dump Java app for student information system for learning and implementing OOPS Concepts like inheritance, abstraction, polymorphism and encapsulation.</p>
  
  <p>What I am doing is, I have created <code>Faculty</code> Class, <code>Student</code> Class and a College Class. Now i want to add new faculty in College. So my approach is to create a method in College class i.e. <code>addFaculty(Faculty f)</code> and <code>fireFaculty(Faculty f)</code>, now i want to add <code>Faculties</code> in <code>College</code> class.</p>
  
  <p>Whats the best way to do it? How do i store list of <code>Faculty</code> Object in <code>College</code> Object. Because i can add more than one faculty and more than one student in college. </p>
  
  <p>Whats the best approach to solve this problem in OOPS?</p>
  
  <p>Here is College.java code which i have implemented, it works fine but is this the best way i can solve it?</p>
  
  <pre><code>public class College 
  {
  String name;
  String location;
  String courses[];
  HashMap&lt;String,Faculty&gt; faculties;
  int noOfFaculties = 0;
  int noOfStudents = 0;
  
  public College(String name,String location,String courses[])
  {
      this.name = name;
      this.location = location;
      this.courses = courses;
      faculties = new HashMap&lt;&gt;();
  }
  
  public void addFaculty(Faculty faculty)
  {
      faculties.put(faculty.getName(),faculty);
  }
  
  public void printFaculties()
  {
      Set&lt;String&gt; set = faculties.keySet();
      if(set.size()&gt;0)
      {
          for(String s:set)
          {
              System.out.println(faculties.get(s).getName());
          }
      }
      else
      {
          System.out.println("No Faculties Currently Working");
      }
  }
  
  public void fireFaculty(Faculty faculty)
  {
      faculties.remove(faculty.getName());
  }
  public String getName()
  {
      return name;
  }
  
  public String getLocation()
  {
      return location;
  }
  
  public String[] getCourses()
  {
      return courses;
  }
  }
  </code></pre>