Easiest way to convert a List to a Set in Java

OHHAI picture OHHAI · Sep 16, 2009 · Viewed 540k times · Source

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

Answer

sepp2k picture sepp2k · Sep 16, 2009
Set<Foo> foo = new HashSet<Foo>(myList);