method to add into arraylist 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 at index
arrlist.add(2,25);