ArrayList,LinkedList,Vector and Stack
ArrayList (Since Java 1.2): Grow able Array implementation of List interface. Insertion order is preserved. Duplicate elements are allowed. Multiple null elements of insertion are allowed. Default initial capacity of an ArrayList is 10. The capacity grows with the below formula, once ArrayList reaches its max capacity. newSize/newCapacity= (oldCapacity * 3)/2 + 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
package com.c2j.collectionframework.list; import java.util.ArrayList; public class ArrayListExample { public static void main(String[] args) { ArrayList arrayList = new ArrayList(); arrayList.add("Sreenath"); arrayList.add("Sreenath"); arrayList.add(10.5); arrayList.add(25); arrayList.add(null); arrayList.add(null); System.out.println(arrayList); } } |
Output: […]