How to Remove an Item From an ArrayList in Java


In this example we will show the method to remove an item from an ArrayList in Java.

Source Code

package com.beginner.examples;

import java.util.ArrayList;

public class RemoveArrayList { 
  public static void main(String[] args) { 
    ArrayList strs = new ArrayList();
    strs.add("a");
    strs.add("b");
    strs.add("c");
    strs.remove(1); // remove an item
    System.out.println(strs);
  } 
}

Output:

[a, c]

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments