java how to create set of of a list code example Example: java list to set Set<Foo> foo = new HashSet<Foo>(myList);