ArrayList practice problems

1. Write a method populateWithIntegers that takes an ArrayList<Integer> and an int n as its inputs and populates the ArrayList with elements 0, 1, 4, 9, ..., n2.

2. Write a method sum that takes an ArrayList<Integer> as its lone input and returns the sum of its elements.

3. Write a method deleteEveryOther that takes an ArrayList as its input and deletes every other element of the ArrayList, starting with the zeroth element.

Example:

If alist contains [0, 1, 2, 3, 4, 8, 10] then after doing deleteEveryOther(alist), alist would contain [1, 3, 8]. This one might be trickier than it looks...