1.

What Are The Methods Added To Collections In Java 9?

Answer»

With java 9, following methods are added to List, Set and MAP interfaces along with their overloaded counterparts.

static <E&GT; List<E> of(E e1, E e2, E e3);

static <E> Set<E> of(E e1, E e2, E e3);

static <K,V> Map<K,V> of(K k1, V V1, K K2, V v2, K k3, V v3);

static <K,V> Map<K,V> ofEntries(Map.Entry<? extends K,? extends V>... entries)

note:

  1. For List and Set interfaces, of(...) method is overloaded to have 0 to 10 parameters and one with var args parameter.
  2. For Map interface, of(...) method is overloaded to have 0 to 10 parameters.
  3. In case of more than 10 paramters for Map interface, ofEntries(...) method can be used accepting var args parameter.

With java 9, following methods are added to List, Set and Map interfaces along with their overloaded counterparts.

static <E> List<E> of(E e1, E e2, E e3);

static <E> Set<E> of(E e1, E e2, E e3);

static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3);

static <K,V> Map<K,V> ofEntries(Map.Entry<? extends K,? extends V>... entries)

note:



Discussion

No Comment Found