Comparison Between Array And ArrayList


Array is collection of homogeneous elements . It means we can only store the same type of data in our array . Let us see with the help of an example.

  1. int[] intList = new int[2];  
  2. intList[0] = 1;  
  3. intList[1] = 2;  

In the above example, I created an array of integer type with its capacity. We can only store 2 integer type elements in the defined array because I have set capacity as two. Array works on the index based system, array index starts with position 0.


In the array first you define which type of value you want to store and how many .You can’t store value as more than its capacity. Array size can’t automatically grow.


  1. ArrayList is available inside the System.Collections namespace.
  2. How to define the ArrayList.
    1. ArrayList arrayList = new ArrayList();  
    In the definition of ArrayList I did not use the capacity.

  3. How to add element to ArrayList.
    We use the add method to add the element to the ArrayList as you can see from below code.
    1. arrayList.Add("shreesh");  
    2. arrayList.Add(2) ;  
  4. You can add object type data to the ArrayList as I added one string and another integer type.
  5. You can add as much value as you want . ArrayList size automatically grows according to new element.

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now