Javatpoint Logo
Javatpoint Logo

Scala HashSet

HashSet is a sealed class. It extends AbstractSet and immutable Set trait. It uses hash code to store elements.

It neither maintains insertion order nor sorts the elements.


Scala HashSet Example

In the following example, we have created a HashSet to store elements. Here, foreach is used to iterate elements.

Output:

0 
6 
2 
45 
3 
8 
4
Next TopicScala BitSet




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA