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

ArrayList default constructor documentation states wrong initial capacity

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The default constructor documentation of java.util.ArrayList class states actually "Constructs an empty list with an initial capacity of ten." where expected is "Constructs an empty list with an initial capacity of zero."

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1)
      From download link (https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html) download the latest jdk version 12 any operating system (for instance : jdk-12.0.1_windows-x64_bin.zip)
      2)
      Extract scr.zip
      3)
      Open ArrayList.java from ...src/java.base/java/uti/
      4)
      Goto default constructor of ArrayList and you will find that 'elementData' (the array bufffer into which the elements of the ArrayList are stored) is being initialized with 'DEFAULTCAPACITY_EMPTY_ELEMENTDATA' (which is Shared empty array instance used for default sized empty instances).
      Which confirms that the default constructor of java.util.ArrayList class actually "Constructs an empty list with an initial capacity of zero BUT NOT ten.
      Which should be corrected in documentation of default constructor of java.util.ArrayList.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The documentation of default constructor of java.util.ArrayList.java should state that "Constructs an empty list with an initial capacity of zero." BUT NOT ten.
      ACTUAL -
      The documentation of default constructor of java.util.ArrayList.java actually states that "Constructs an empty list with an initial capacity of ten."

      FREQUENCY : always


            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: