Snippet 1
//Create the ArrayList
List al = new ArrayList<>();
//Add the items
al.add(10);
al.add(18);
//Remove item(1 = 2and item in list)
al.remove(1);
Snippet 2
//create ArrayList
ArrayList arrayList = new ArrayList();
//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");
Similar Snippets
Find Duplicates In Arraylist Java Code Example – java
Creating Java Main Method Code Example – java
Create Copy Of Array From Another Array Code Example – java
Copyright © Code Fetcher 2020