< prev index next >

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

Print this page
rev 50902 : [mq]: 8206123-ArrayDeque-created-with-default-constructor-can-only-hold-15-elements

@@ -178,11 +178,12 @@
     /**
      * Constructs an empty array deque with an initial capacity
      * sufficient to hold 16 elements.
      */
     public ArrayDeque() {
-        elements = new Object[16];
+        // One extra slot for a null element at the tail
+        elements = new Object[16 + 1];
     }
 
     /**
      * Constructs an empty array deque with an initial capacity
      * sufficient to hold the specified number of elements.
< prev index next >