... printList(list1); // print list1 elements
30
31         convertToUppercaseStrings(list1); // convert to uppercase string
32         printList(list1); // print list1 elements
33
34         System.out.printf("%nDeleting elements 4 to 6…");
35         removeItems(list1, 4, 7); // remove items 4-6 from list
36         printList(list1); // print list1 elements
37         printReversedList(list1); // print list in reverse order
38      }
39
40      // output List contents
41      private static void printList(List<String> list) {
42         System.out.printf("%nlist:%n");
43
44         for (String color : list) {
45            System.out.printf("%s ", color);
46         }
47
48         System.out.println();
49      }
50
51      // locate String objects and convert to uppercase
52      private static void convertToUppercaseStrings(List<String> list) {
53         ListIterator<String> ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.