import java.util.*; import java.lang.*; public class StudentList { public static void iterateList1(List students) { for(Student st: students) { System.out.println(st.toString()); } } public static void iterateList2(List students) { ListIterator it = students.listIterator(); System.out.println("####### Forward ########"); while( it.hasNext() ) { System.out.println(it.next().toString()); } System.out.println("####### Reverse ########"); while( it.hasPrevious() ) { System.out.println(it.previous().toString()); } } public static void iterateList3(List students) { for(int i=0; i students; students = new LinkedList(); students.add(new Student("John", "Smith")); // add at the end of the list students.add(0, new Student("Stanley", "Peters")); // add the beginning of the list students.add(1, new Student("Edgar", "Bloch")); // add at pos 1 of the list students.add(2, new Student("Suzan", "Miles")); // add at pos 1 of the list students.add(0, new Student("Mary", "Poppins")); // add the beginning of the list iterateList1(students); System.out.println("---------"); iterateList2(students); System.out.println("---------"); iterateList3(students); } }