Question 1081
Multiple choice
Using Text Files
A text file contains five lines, each with a single integer:
After reading all values into an
1020101030After reading all values into an
ArrayList<Integer>, the following code attempts to remove all occurrences of 10 using forward traversal. What is the size of the list after the loop?
for (int i = 0; i < list.size(); i++) {
if (list.get(i).intValue() == 10) {
list.remove(i);
}
}
System.out.println(list.size());
Pick an answer, then check it. The solution opens in a window.
BCorrect answer
Answer images

