O'Reilly logo
  • You Wang thinks this is interesting:

List<String> staff = new LinkedList<>(); // LinkedList implements List
staff.add("Amy");
staff.add("Bob");
staff.add("Carl");
Iterator iter = staff.iterator();
String first = iter.next(); // visit first element
String second = iter.next(); // visit second element
iter.remove(); // remove last visited element

From

Cover of Core Java® Volume I—Fundamentals, Tenth Edition

Note

use interface to define a collection, and use initialization to give it an implementation