How to initialize a Set using Eclipse Collections
Initializing a Set using Eclipse Collections is simple and flexible.
I answered the following question on Stack Overflow several years ago.
How to initialize HashSet values by construction?
If you are looking for the most compact way of initializing a set then that was in Java9: Set strSet = Set.of("Apple"…
If you prefer
of instead of
with, the following will work just as well.
If you’d like to understand why Eclipse Collections supports both
with methods on factory classes, the following blog will help.
Thanks for reading! Enjoy!