Question: After each commented section, explain what the data structure looks like at that point in the code. (2 points each, 8 points total). ArrayList numbers;
-
After each commented section, explain what the data structure looks like at that point in the code. (2 points each, 8 points total).
ArrayList
numbers; numbers = new ArrayList<>();
for(int i=90; i<=100; i++)
numbers.add(i);
//picture 1
numbers.set(numbers.size()-1, 10);
numbers.remove(new Integer(91));
numbers.remove(0);
//picture 2
LinkedList
aList; aList = new LinkedList<>();
for(int i=10; i>=1; i--){
aList.addFirst(i);
}
//picture 3
aList.removeLast();
aList.addFirst(100);
aList.addFirst(aList.getLast());
//picture 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
