Operator + cannot be applied to double,java.lang.Object?

for (int j = 0; j < list.size(); j++) { // total += list.get(j); } Is a code that is supposed to add up all the sums of a ArrayList, blanked line is where the error is happening. System.out.print("Enter list of numbers\n"); while (sn.hasNextInt()) { number =... show more for (int j = 0; j < list.size(); j++) {
// total += list.get(j);
}
Is a code that is supposed to add up all the sums of a ArrayList, blanked line is where the error is happening.

System.out.print("Enter list of numbers\n");

while (sn.hasNextInt()) {
number = sn.nextInt();
list.add(new Integer(number));
}

Is how the numbers are added to the ArrayList.
Update: sn is an Scanner and total, number are declared integers.
1 answer 1