Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; public class ArrayListRemoveExample5{ public static void main(String[] args){ List
countries = new ArrayList<>(); countries.add(0, "USA"); // ["USA"] countries.add(1, "England"); // ["USA", "England"] countries.remove(2); // throws IndexOutOfBoundsException } }
Output