< prev index next >

src/java.base/share/classes/java/util/Set.java

Print this page

        

*** 446,458 **** * @param <E> the {@code Set}'s element type * @return an empty {@code Set} * * @since 9 */ - @SuppressWarnings("unchecked") static <E> Set<E> of() { ! return (Set<E>) ImmutableCollections.SetN.EMPTY_SET; } /** * Returns an unmodifiable set containing one element. * See <a href="#unmodifiable">Unmodifiable Sets</a> for details. --- 446,457 ---- * @param <E> the {@code Set}'s element type * @return an empty {@code Set} * * @since 9 */ static <E> Set<E> of() { ! return ImmutableCollections.emptySet(); } /** * Returns an unmodifiable set containing one element. * See <a href="#unmodifiable">Unmodifiable Sets</a> for details.
*** 691,703 **** @SafeVarargs @SuppressWarnings("varargs") static <E> Set<E> of(E... elements) { switch (elements.length) { // implicit null check of elements case 0: ! @SuppressWarnings("unchecked") ! var set = (Set<E>) ImmutableCollections.SetN.EMPTY_SET; ! return set; case 1: return new ImmutableCollections.Set12<>(elements[0]); case 2: return new ImmutableCollections.Set12<>(elements[0], elements[1]); default: --- 690,700 ---- @SafeVarargs @SuppressWarnings("varargs") static <E> Set<E> of(E... elements) { switch (elements.length) { // implicit null check of elements case 0: ! return ImmutableCollections.emptySet(); case 1: return new ImmutableCollections.Set12<>(elements[0]); case 2: return new ImmutableCollections.Set12<>(elements[0], elements[1]); default:
< prev index next >