How do I create a method that satisfies the following conditions?
/*
* removes all occurrences (if any) of x in the ArrayList object that the parameter list
* is referencing. If there is no occurrence of x then the content of the ArrayList
* is not altered.
*/
void removeOccurrences(ArrayList<Integer> list, int x)
NOTE: One may think on an algorithm such as the following:
for (int i=0; i<list.size(); i++)
if (list.get(i) == x)
list.remove(i);