How to convert List to Set (ArrayList to HashSet)
Collection object has a constructor that accept a Collection object to initial the value. Since both Set and List are extend the Collection, the conversion is quite straightforward. It’s just pass a List into Set constructor or vice verse. Convert List to Set Set set = new HashSet(list); Convert Set to List List list = …