reverse in arraylist code example
Example 1: how to reverse order of arraylist
ArrayList<Integer> arrlist = new ArrayList<Integer>();
Collections.reverse(arrlist);
Collections.sort(arrlist, Collections.reverseOrder());
Example 2: Arraylist reverse in java
public static void main(String[] args) {
ArrayList<Integer>list = new ArrayList<>();
for(int i = 1; i < 6; i++){
list.add(i);
}
System.out.println(list);
for (int i = list.size()-1; i >= 0; i--) {
int each = list.get(i);
System.out.print(each + " ");
}