CHALLENGE ACTIVITY
8.27.1: Modifying ArrayList using add and remove
Modify the existing ArrayList's contents by erasing the second element, then inserting 100 and 102 in the shown locations. Use ArrayList's remove and add methods only. Sample ArrayList content of the below program:
100 101 102 103
import java.util.ArrayList;
public class ArrayListADT {
public static void main(String[] args) {
ArrayList<Integer> numsList = new ArrayList<Integer>();
int numOfElem = 4;
numsList.add(101);
numsList.add(200);
numsList.add(103);
/* Your solution goes here */
System.out.println(numsList);
}
}