Java Writing A Remove From Arraylist Code Example

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

Java Creat A Folder Code Example - java

Firestore Find Doc And Set Data Code Example - java