src/share/classes/java/util/ArrayList.java

Print this page




 104 {
 105     private static final long serialVersionUID = 8683452581122892189L;
 106 
 107     /**
 108      * The array buffer into which the elements of the ArrayList are stored.
 109      * The capacity of the ArrayList is the length of this array buffer.
 110      */
 111     private transient Object[] elementData;
 112 
 113     /**
 114      * The size of the ArrayList (the number of elements it contains).
 115      *
 116      * @serial
 117      */
 118     private int size;
 119 
 120     /**
 121      * Constructs an empty list with the specified initial capacity.
 122      *
 123      * @param   initialCapacity   the initial capacity of the list
 124      * @exception IllegalArgumentException if the specified initial capacity
 125      *            is negative
 126      */
 127     public ArrayList(int initialCapacity) {
 128         super();
 129         if (initialCapacity < 0)
 130             throw new IllegalArgumentException("Illegal Capacity: "+
 131                                                initialCapacity);
 132         this.elementData = new Object[initialCapacity];
 133     }
 134 
 135     /**
 136      * Constructs an empty list with an initial capacity of ten.
 137      */
 138     public ArrayList() {
 139         this(10);
 140     }
 141 
 142     /**
 143      * Constructs a list containing the elements of the specified
 144      * collection, in the order they are returned by the collection's




 104 {
 105     private static final long serialVersionUID = 8683452581122892189L;
 106 
 107     /**
 108      * The array buffer into which the elements of the ArrayList are stored.
 109      * The capacity of the ArrayList is the length of this array buffer.
 110      */
 111     private transient Object[] elementData;
 112 
 113     /**
 114      * The size of the ArrayList (the number of elements it contains).
 115      *
 116      * @serial
 117      */
 118     private int size;
 119 
 120     /**
 121      * Constructs an empty list with the specified initial capacity.
 122      *
 123      * @param  initialCapacity  the initial capacity of the list
 124      * @throws IllegalArgumentException if the specified initial capacity
 125      *         is negative
 126      */
 127     public ArrayList(int initialCapacity) {
 128         super();
 129         if (initialCapacity < 0)
 130             throw new IllegalArgumentException("Illegal Capacity: "+
 131                                                initialCapacity);
 132         this.elementData = new Object[initialCapacity];
 133     }
 134 
 135     /**
 136      * Constructs an empty list with an initial capacity of ten.
 137      */
 138     public ArrayList() {
 139         this(10);
 140     }
 141 
 142     /**
 143      * Constructs a list containing the elements of the specified
 144      * collection, in the order they are returned by the collection's