Suppose we know how to combine students into an iterable class ArrayList. Fill in either y or n for the following questi

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Suppose we know how to combine students into an iterable class ArrayList. Fill in either y or n for the following questi

Post by answerhappygod »

Suppose we know how to combine students into an iterable class
ArrayList.
Fill in either y or n for the following
questions.
Suppose We Know How To Combine Students Into An Iterable Class Arraylist Fill In Either Y Or N For The Following Questi 1
Suppose We Know How To Combine Students Into An Iterable Class Arraylist Fill In Either Y Or N For The Following Questi 1 (206.14 KiB) Viewed 65 times
Suppose we know how to combine students into an iterable class ArrayList. • First the enrolled students, in alpha order • Then the waitlisted students, in sign-up order • Then the hopeful students, in random order - uses Collections.shuffle() The function below will do the work and return iterable class ArrayList so that the enhanced for- loop will follow the order when we combined the students. private ArrayList<Students collectToList() { ArrayList<Student> all students = new ArrayListo (enrolled); all Students.addAll(waitList); ArrayList<Student> hopelist = new ArrayList<>Choping); // Randomize the hoping students. Collections. shuffle(hopelist); // Randomize the hoping students all Students.addAll(hopelist); return allStudents; } Then we can simplify the implementation of method iterator() as follows: public Iterator<Student> iterator {. return collectToList().iterator(); } Fill in either y or n for the following questions. (y/n) We can combine students into another iterable class TreeSet instead of ArrayList. The enhanced for-loop will still follow the order when we combined the students. That is, we could change collectToList as follows: private TreeSet<Students collectToList() { // combine students into TreeSet and return it } (y for yes, n for no) (y/n) We can combine students into another iterable class HashSet instead of ArrayList. The

(y/n) We can combine students into another iterable class HashSet instead of ArrayList. The enhanced for-loop will still follow the order when we combined the students. That is, we could change collectToList as follows: private HashSet<Student> collectToList() { // combine students into HashSet a nd return it } (y for yes, n for no)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply