Check out example codes for "java how to create arraylist". It will help you in understanding the concepts better.

Code Example 1

import java.util.ArrayList;

public class MyClass {
  public static void main(String[] args) {
    ArrayList<String> cars = new ArrayList<String>();
    cars.add("Volvo");
    cars.add("BMW");
    cars.add("Ford");
    cars.add("Mazda");
    System.out.println(cars);
  }
}

Code Example 2

//create ArrayList
ArrayList<String> arrayList = new ArrayList<String>();
//add item to ArrayList
arrayList.add("item");
//check if ArrayList contains item (returns boolean)
System.out.println(arrayList.contains("item"));
//remove item from ArrayList
arrayList.remove("item");

Code Example 3

import java.util.ArrayList;
//create ArrayList
ArrayList<String> arrayList = new ArrayList<String>();

Code Example 4

import java.util.ArrayList;

Learn ReactJs, React Native from akashmittal.com