Revised collapseDuplicates

Still need to add things into main method to be able to test whether
the collapseDuplicates method works.
Minor changes to collapseDuplicates()

Realized that ArrayList<Integer> doesn’t work like a regular array and
needs the get() method to retrieve objects.
Added test cases & collapseDuplicate() successful