ArrayList in Java


Prev Tutorial Next Tutorial

ArrayList in Java

ArrayList is a replacement of vector class, It is a new class used to store multiple objects.

In ArrayList the data is organizing in the form of cells. Cell values are storing in heap memory and cell address are storing in associative memory.


Points to Remember

  • ArrayList class is not Synchronized.
  • ArrayList class elements can be access randomly.
  • In the ArrayList value will be stored in the same order as inserted.
  • ArrayList class uses a dynamic array for storing the elements.It extends AbstractList class and implements List interface.
  • ArrayList class can contain duplicate elements.
  • ArrayList allows random access because array works at the index basis.

Note: ArrayList calss contains same methods like vector.

Creating ArrayList is nothing but creating an object of ArrayList class.


ArrayList al=new ArrayList();

Arraylist Constructor

ArrayList(): This constructor is used for creating an object of ArrayList class.


ArrayList al=new ArrayList()

Advantages of ArrayList

  • ArrayList based applications takes less memory space.
  • Retrieving the data from ArrayList will take less time.
  • Performance of ArrayList based applications is more.

Difference Between Vector and ArrayList

1Vector is legacy Collection Framework (old class).ArrayList is new Collection Framework.
2Vector is Synchronized by default.ArrayList is not Synchronized.
3For retrieving elements from Vector class can be use foreach loop, iterator, listiterator and enumeration.For retrieving elements from ArrayList class can be use foreach loop, iterator and listiterator.

Example of ArrayList

import java.util.Arraylist;

class DemoArraylist
public static void main(String args[])

ArrayList<Integer> al=new ArrayList<Integer>();  // creating arraylist

Iterator itr=al.iterator();  // getting Iterator from arraylist to traverse elements  



Prev Tutorial Next Tutorial


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements

Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: or 9999595223 Try this Keyword C++ Programs