how to use the arraylist add function in java code example
Example 1: java arraylist add
//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");
Example 2: arraylist add method
public void add(int index, E element) // no return value