What are the important methods in a Set?

The most important methods in a Set are

boolean add(E e);
boolean remove(Object o);
int size();
Iterator iterator();
boolean contains(Object o);

add(), remove(), size() and contains() make sense but why is iterator() an important method? Simply because Iterator is the only straightforward way to iterating over a Set since we do not have indexes.

 

CORE JAVA COLLECTIONS