You could use the Set iterator instead with .next() and .hasNext()