Easy way to create a Set in Java

Опубликовано: 10 Июль 2026
на канале: CSExplained
213
8

If you've seen my shorts before, you've probably noticed that I use List.of a lot! However, there is also a Set.of() static method that does something very similar to List.of(), but instead gives you a Set data structure instead. Again, a downside to using this is that this would produce an immutable set, so you won't be able to modify it once you've created the object, but as you can see, the code looks super clean and there isn't a lot of boilerplate code.

#shorts