public static int sum(ArrayList<Integer> list) {
int total = 0;
for (int i = 0; i < /* missing */; i++) {
total += list.get(i);
}
return total;
}Which expression correctly replaces /* missing */?
- A
list.size
- Bcheck_circle
list.size()
- C
list.length()
- D
list.length
Explanation
ArrayList uses size(), a method call. length is a property of arrays, and length() applies to Strings.