MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

collections/ListIteration.java:9–28  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

7
8public class ListIteration {
9 public static void main(String[] args) {
10 List<Pet> pets = new PetCreator().list(8);
11 ListIterator<Pet> it = pets.listIterator();
12 while(it.hasNext())
13 System.out.print(it.next() +
14 ", " + it.nextIndex() +
15 ", " + it.previousIndex() + "; ");
16 System.out.println();
17 // Backwards:
18 while(it.hasPrevious())
19 System.out.print(it.previous().id() + " ");
20 System.out.println();
21 System.out.println(pets);
22 it = pets.listIterator(3);
23 while(it.hasNext()) {
24 it.next();
25 it.set(new PetCreator().get());
26 }
27 System.out.println(pets);
28 }
29}
30/* Output:
31Rat, 1, 0; Manx, 2, 1; Cymric, 3, 2; Mutt, 4, 3; Pug,

Callers

nothing calls this directly

Calls 7

listMethod · 0.80
printMethod · 0.80
nextMethod · 0.65
setMethod · 0.65
getMethod · 0.65
hasNextMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected