Answer:
Include the conditional case when pList is equal to zero.
Step-by-step explanation:
// Initially it is necessary to import the libraries
import java.util.*;
import java.io.*;
public class H01_34 {
public Integer arrayListSum(ArrayList<Integer> pList) {
// You might have forgotten the possibility when the pList is zero.
if (pList == null) {
//once pList is null it will return 0 to the main
return 0;
}
int sum = 0;
for (int i = 0; i < pList.size(); i++) {
sum += pList.get(i);
}
return sum;
}
}