Problem

7/10

Reverse ArrayList

Theory Click to read/hide

Reverse ArrayList
The Collections  interface also provides methods for bulk operations that work on the entire collection:
containsAll - returns the boolean value true if this collection contains all the elements in the called collection, otherwise it returns false.
addAll - adds all of the specified elements to the specified collection. The elements to be added can be specified individually or as an array.
removeAll -  is used to remove all elements from the list that are contained in the specified collection.
clear - remove all elements
reverse - array reverse
etc.

Example
Using removeAll. ArrayList<Integer> first = new ArrayList<Integer>(); first.add(1); first.add(2); first.add(3); ArrayList<Integer> second = new ArrayList<Integer>(); second.add(1); second.add(2); // removes all elements from the second list, // if they exist in the first list second.removeAll(first);

Problem

Given a sequence of integers. Write a program that reverses an array using Collections.reverse.

Input: first given number N — the number of elements in the sequence (\(1<= N <= 100\)). Then N numbers are written separated by a space.
 
Output: you need to output an array sorted in descending order by the last digit in the number.
 
Examples
# Input Output
1 5
1 2 3 4 5
5 4 3 2 1