list of string to set of long java 8 code example Example: java list to set Set<Foo> foo = new HashSet<Foo>(myList);