Because non-generic Lists return objects. As you see, you declared the array to hold Object-type elements, so you need to cast them to Integer before you can use a mathematical operation on them. This is solved by using generics, instead of:

Code:

ArrayList list;

you use

Code:

ArrayList<Integer> list;

This way, the List will only accept Integer objects, and also return Integers (no need to cast).