Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is the primary advantage of using a for-each loop?
Think about simplicity and safety.
What method would you use to check if there are more elements in an Iterator?
It starts with 'has'.
Which of the following is a method of the Iterator interface?
This method starts with 'n'.
True or False: You can safely modify a collection while using a for-each loop.
Think about the safety of the iteration process.
Given a list of names, write a Java program that uses an Iterator to remove any name that starts with 'J' and print the remaining names.
Use the startsWith() method to check the first letter.
Create a program that uses both for-each and Iterator to gather elements from a list into two separate lists: one for names longer than 4 characters and another for shorter names.
Evaluate the length of each name during iteration.
5 more questions in this section. Enroll free to practise them all.
Enroll free