Languages
[Edit]
EN

Java - different ways of how to iterate over Set or HashSet

14 points
Created by:
Joann-Calderon
383

1. Overview

Edit

In java we can traverse over Set or HashSet with different ways.

Old ways involve Iterator, with java 8 we can use stream / forEach.

There is also an ancient way with Enumeration.

Below we can see 7 different ways of how to iterate over Set in java.

2. Code example

Edit

Output:

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - collections

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join