We may use Iterator to iterate through a HashSet. Consider the code snippet below:

Java Code:
Set set = new HashSet();
set.add("Cricket");
set.add("Football");
set.add("Cricket");
set.add("Rugby");
set.add("Cricket");
System.out.println(set);

Iterator it = set.iterator();

while(it.hasNext())
System.out.println(it.next());
Output:

Java Code:
Rugby
Cricket
Football