Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8161033

Add default method addAll(T...elements) to java.util.Collection

XMLWordPrintable

      A DESCRIPTION OF THE REQUEST :
      To add an array to a Collection we can use Collections.addAll(Collection<? super T> c, T... elements). It should be possible to add an array of elements directly to a collection.

      JUSTIFICATION :
      This extension improves the readability and clearity of code.

      addAll(collection,array)

      vs

      collection.addAll(array)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Collection.add(T ...elements) should behave exactly as Collections.addAll(Collection<? super T> c, T... elements).

      ---------- BEGIN SOURCE ----------
       Collection<String> c = new ArrayList<String>();
       c.addAll( "a","b","c" );
              
      assertThat(c).containsExactly("a","b","c");
      ---------- END SOURCE ----------

            smarks Stuart Marks
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: