Check out example codes for "java insert into arraylist". It will help you in understanding the concepts better.

Code Example 1

ArrayList<Integer> str=new ArrayList<Integer>();
str.add(0);
str.add(1);
 // Result = [0, 1]
    
str.add(1, 11);
 // Result = [0, 11, 1]

Code Example 2

public void add(int index, E element)
// adding element 25 at third position
arrlist.add(2,25);

Learn ReactJs, React Native from akashmittal.com