Give the names of the two methods that we have to have to implement interface Iterator as shown in RED below.
Posted: Fri May 20, 2022 5:05 pm
Give the names of the two methods that we have to have to
implement interface Iterator <Student> as shown
in RED below.
Enhanced for loop requires some effort. We have to do some work (making class iterable) before you can use it. Suppose we have the following collection class Roster that contains members of class Student. public class Roster { private int maxEnrolled; private int maxWaitlist; private int totalwithhope; private TreeSet<Student> enrolled; private ArrayList<Student> waitList; private HashSet<Student> hoping; } To make class Roster to be iterable, we can add an inner class Rosterlterator that implements Iterator <Student>. Give the names of the two methods that we have to have to implement interface Iterator <Student> as shown in RED below. B public class Roster implements Iterable<Student> { public Iterator<Student> iterator() { return new RosterIterator; } private class RosterIterator implements Iterator<Student> { public boolean A___O { }; public Student _B___O {...}; } }
implement interface Iterator <Student> as shown
in RED below.
Enhanced for loop requires some effort. We have to do some work (making class iterable) before you can use it. Suppose we have the following collection class Roster that contains members of class Student. public class Roster { private int maxEnrolled; private int maxWaitlist; private int totalwithhope; private TreeSet<Student> enrolled; private ArrayList<Student> waitList; private HashSet<Student> hoping; } To make class Roster to be iterable, we can add an inner class Rosterlterator that implements Iterator <Student>. Give the names of the two methods that we have to have to implement interface Iterator <Student> as shown in RED below. B public class Roster implements Iterable<Student> { public Iterator<Student> iterator() { return new RosterIterator; } private class RosterIterator implements Iterator<Student> { public boolean A___O { }; public Student _B___O {...}; } }