convert list to set in java code example
Example 1: java list to set
Set<Foo> foo = new HashSet<Foo>(myList);
Example 2: convert set to list java
public void givenUsingCoreJava_whenSetConvertedToList_thenCorrect() {
Set<Integer> sourceSet = Sets.newHashSet(0, 1, 2, 3, 4, 5);
List<Integer> targetList = new ArrayList<>(sourceSet);
}
Example 3: convert list to set python
names = ['Barry', 'Alice', 'Bob', 'Bob']
unique_names = set(names)
# Result:
# {'Alice', 'Barry', 'Bob'}