Creating an ArrayList Object
In this lesson, you'll learn how to create an ArrayList object in Java.
Let’s practically use an ArrayList Object in our code. The ArrayList
is a class in Java and to use a class’s functionality we have to instantiate it i.e. to construct its object.
To construct an object
of a class
we use a constructor. Before we jump to the constructor part let’s discuss a bit about the wrapper classes
.
Wrapper classes
In Java, we cannot directly instantiate an ArrayList of the primitive data types like int, char, boolean
. The reason for this is that primitive data types are not objects. For this purpose, Java has inbuilt wrapper classes
which just wrap these
primitive data types in a class
. Below given is the list of inbuilt ...