Skip to content

Instantly share code, notes, and snippets.

@yavuztas
Last active August 27, 2019 15:25
Show Gist options
  • Save yavuztas/b10cd51c4742c0e84578cc9779fec96c to your computer and use it in GitHub Desktop.
Save yavuztas/b10cd51c4742c0e84578cc9779fec96c to your computer and use it in GitHub Desktop.
Created with Copy to Gist
public static <T> Set<T> toSet(T[] array) {
return UtilsForCollections.toSet(array, false);
}
public static <T> Set<T> toSet(T[] array, boolean preserveOrder) {
if (preserveOrder) {
return Arrays.stream(array)
.collect(Collectors.toCollection(LinkedHashSet::new));
}
return Arrays.stream(array).collect(Collectors.toSet());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment