Abstract


The Mother of All Classes


  • java.lang.Object is the root of all classes in Java. Whether they are part of the Java libraries or custom classes you create yourself, all classes implicitly inherit from java.lang.Object

Java Iterator


  • An OOP Object of the java.util.Iterator OOP Class that can be used to loop through collections like ArrayList and HashSet

Obtaining a Java Iterator

Iterator<T> it = cars.iterator();, where cars is an instance of Java collections.

Get the first element of a collection using Java iterator

it.next(); returns the first element of a collection, where it is a Java iterator.

Loop through a collection using Java iterator

while(it.hasNext()) {System.out.println(it.next());}, where it is a Java iterator.

Remove an element from a collection using Java iterator

it.remove();, where it is a Java iterator.