import java.util.*; import java.lang.*; import java.util.*; import java.lang.*; public class StudentCollection { private Collection students; public StudentCollection() { students = new LinkedList(); populateList(); } public final void populateList() { students.add(new Student("John", "Smith")); students.add(new Student("Stanley", "Peters")); students.add(new Student("Edgar", "Bloch")); students.add(new Student("Suzan", "Miles")); students.add(new Student("Mary", "Poppins")); } public Collection getStudents() { return students; } public void iterateList() { for(Student st: students) { System.out.println(st.toString()); } } public static void main(String args[]) { StudentCollection stl = new StudentCollection(); Collection sts = new LinkedList(); //comment for statement int i=0; for(Student st : stl.getStudents()) { sts.add(st); if(++i==2) break; } //and uncomment this code below /* sts.add(new Student("John", "Smith")); sts.add(new Student("Stanley", "Peters")); */ stl.getStudents().removeAll(sts); stl.iterateList(); } }