How to create ArrayList in Java?
Ask by Utpal Vishwas
Updated 22 Jul 2023
There are two ways to create an array list in Java:
ArrayList()constructor. TheArrayList()constructor creates an empty array list.add()method. Theadd()method adds an element to the end of the array list.Here is an example of how to create an array list and add some elements to it:
Output:
Here are some important things to note about creating array lists: