Java Reference
In-Depth Information
Exercise 4.83 Rewrite the listAllFiles method in the MusicOrganizer class from
music-organizer-v3 by using a for loop rather than a for-each loop.
Exercise 4.84 Java provides another type of loop: the do-while loop . Find out how this loop
works and describe it. Write an example of a do-while loop that prints out the numbers from
1 to 10. To find out about this loop, find a description of the Java language (for example, at
http://download.oracle.com/javase/tutorial/java/nutsandbolts/
in the section "Control Flow Statements").
Exercise 4.85 Rewrite the listAllFiles method in the MusicOrganizer class from
music - organizer - v3 by using a do-while loop rather than a for-each loop. Test your solu-
tion carefully. Does it work correctly if the collection is empty?
Exercise 4.86 Challenge exercise Rewrite the findFirst method in the MusicOrganizer
class from music-organizer-v4 by using a do-while loop rather than a while loop. Test your solu-
tion carefully. Try searches that will succeed and others that will fail. Try searches where the file
to be found is first in the list and also where it is last in the list.
Exercise 4.87 Find out about Java's switch-case statement . What is its purpose? How is
it used? Write an example. (This is also a control flow statement , so you will find information in
similar locations as for the do-while loop .)
Search WWH ::




Custom Search