
The Arrays.asList() method accepts an array as a parameter and returns a fixed-size list. Adding elements of array to ArrayList using Arrays.asList() We can add the elements of the array to the ArrayList. value of index 2 is changed in arrylist adding ArrayLisr al to the ArrayList arrylist Now if we change the value of the ArrayList arrylist, it is not affected in the ArrayList al. In this example, we are adding the elements of the ArrayList al to the ArrayList arrylist. When we are using this approach, if the value of one ArrayList is changed, it will not reflect in the other ArrayList.

We can add elements of one ArrayList to another by passing the first ArrayList to the second ArrayList's constructor.

adding elements of bird ArrayList to animal ArrayListĪdding elements of one ArrayList to another using constructor Finally we add all the elements of the bird to the animal using addAll() method. Then we create another ArrayList bird and add elements to it. In this example, firstly we create an ArrayList animal and add elements to the ArrayList using the add() method.

Add elements of one ArrayList to another ArrayList
