Java – Easiest way to convert a List to a Set in Java

collectionsjava

What is the easiest way to convert a List to a Set in Java?

Best Answer

Set<Foo> foo = new HashSet<Foo>(myList);