import java.util.*;

// Reverse arraylist

public class HelloWorld {
    public static void main(String[] args) {
      
      reverseList(new ArrayList<>(Arrays.asList(10, 20, 30, 40, 50)));
      // 50 40 30 20 10
      
      reverseList(new ArrayList<>(Arrays.asList(.99, .88, .77, .66)));
      // .66 .77 .88 .99
      
      reverseList(new ArrayList<>(Arrays.asList(true, false, true, false)));
      // false true false true
      
      reverseList(new ArrayList<>(Arrays.asList(3.145988F, 888111999L, true, 10, '#')));
    }
    
    static void reverseList(ArrayList<Object> list)
    {
      // create a temp ArrayList of object type
      ArrayList<Object> tempList = new ArrayList<>();
      
      // get the last element and store it ; starting point in the loop
      int lastIndex = list.size() -1;
      
      // iterate thru and add reversed values inside temp ArrayList
      for(int i = lastIndex; i>=0; i--){
        tempList.add(list.get(i)); // store each value inside tempList one at a time
      }
      // print out the reversed values
      System.out.println(tempList);
    }
    
} 
by