Like this: Set<T> mySet = new HashSet<>(Arrays.asList(someArray));. In Java 9+, if unmodifiable set is ok: Set<T> mySet = Set.of(someArray);.
確定! 回上一頁