Iterator j = testHashSet.iterator(); do { System.out.println(" Retrieved Item " + (index + 1) + ": " + j.next() + "."); index++; }while(j.hasNext());