ArrayList in Java

ArrayList:

  • ArrayList is resizable-array implementation of the List interface.
  • It implements all optional list operations, and permits all elements, including null.
  • This class provides methods to manipulate to the size of array that is used internally to store the list. (This class is roughly equivalent to Vector, except that it is unsynchronized.)
  • Java ArrayList class can contain duplicate elements.
  • Java ArrayList class maintains insertion order.
  • Java ArrayList allows random access because array works at the index basis.
  • Manipulation in ArrayList is slow because a lot of shifting needs to be done if any element is added or remove in arraylist.

Let’s understand how to use ArrayList with examples.

ArrayList Basics:

Add and Remove elements:

Sort ArrayList:

Other Useful Functions on ArrayList:

 

Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...