Is there a convenience method to initialize a Set equivalent to Collections.singleton, which returns a mutable Set instead of an immutable one?
            Asked
            
        
        
            Active
            
        
            Viewed 1.5k times
        
    9
            
            
         
    
    
        Rian Schmits
        
- 3,096
- 3
- 28
- 44
2 Answers
11
            
            
        Guava is defintely a good solution.
Alternatively, you can do:
Set<T> mySet = new HashSet<>(Arrays.asList(t1, t2, t3));
 
    
    
        Jean Logeart
        
- 52,687
- 11
- 83
- 118
