How to create checked Set with one (or more elements)
I have some Objects of type A and I want to create checked Set with all these objects
A element1; //not null
A element2; //not null; optional
my solution:
Set<A> s = new HashSet<>(1);
a.add(element1);
a.add(element2); //optional
Q: Is there any standard util class to create it in simple way?
Something like
List<A> l = java.util.Arrays.asList(element1);
List<A> l = java.util.Arrays.asList(element1, element2); // optional
but for Set