| 67 | it.set("47"); |
| 68 | } |
| 69 | public static void testVisual(List<String> a) { |
| 70 | System.out.println(a); |
| 71 | List<String> b = LIST; |
| 72 | System.out.println("b = " + b); |
| 73 | a.addAll(b); |
| 74 | a.addAll(b); |
| 75 | System.out.println(a); |
| 76 | // Insert, remove, and replace elements |
| 77 | // using a ListIterator: |
| 78 | ListIterator<String> x = |
| 79 | a.listIterator(a.size()/2); |
| 80 | x.add("one"); |
| 81 | System.out.println(a); |
| 82 | System.out.println(x.next()); |
| 83 | x.remove(); |
| 84 | System.out.println(x.next()); |
| 85 | x.set("47"); |
| 86 | System.out.println(a); |
| 87 | // Traverse the list backwards: |
| 88 | x = a.listIterator(a.size()); |
| 89 | while(x.hasPrevious()) |
| 90 | System.out.print(x.previous() + " "); |
| 91 | System.out.println(); |
| 92 | System.out.println("testVisual finished"); |
| 93 | } |
| 94 | // There are some things that only LinkedLists can do: |
| 95 | public static void testLinkedList() { |
| 96 | LinkedList<String> ll = new LinkedList<>(); |