Is ArrayList a class in Java?

Java ArrayList is perhaps the simplest and one of the most used data structure implementation classes of the Java API Library. It is a part of the Java Collection Framework under the java.util package. On one hand, it behaves like a normal array, providing all the benefits of it and, on the other, it is a generic re-sizable collection implementation of the List interface. Java ArrayList is especially used for managing a large number of objects. This article attempts to provide some information of this utility class with a brief overview of its structure.

Java ArrayList Class Hierarchy

In short, Java ArrayList is a subclass of AbstractList and implements the List interface, and List is an extension of the Collection interface. As a result, we can declare an ArrayList object as any of the ways that follow:

  • Collection collection=new ArrayList[];
  • List list=new ArrayList[];
  • ArrayList alist=new ArrayList[];


Figure 1: An ArrayList chart

Refer to the Java API Documentation for more details on the classification.

Java ArrayList Overview

While dealing with data structures in any programming language, we resort to low-level manipulation of data. Creating each element of the data structure dynamically and modifying them by directly manipulating references to it can be erroneous and also daunting at times. Direct manipulation may be necessary on occasion, yet when productivity is concerned, support from the API library comes in quite handy. Java Collection Framework contains many such prepackaged data structures, interfaces, and algorithms. Java ArrayList is one of them and can be used like the low-level arrays with some special connotation.

Java ArrayList uses an array as the internal programming construct to store elements. An array is nothing but a sequential collection same type of elements, accessed by their index values. Naturally, Java ArrayList also behaves in a similar manner. Here, the behavior is defined by the ready-made methods of the ArrayList class. Common operations are add/remove elements in various ways, determine if the list is empty, obtain the size of the list indicated by number of elements present currently, and so forth.

Java ArrayList Constructors

Java ArrayList class contains three constructors, such as:

  • ArrayList[]: Constructs an empty list with an initial storage capacity of ten elements.
  • ArrayList[Collection

Chủ Đề