fork download
  1. import java.util.Arrays;
  2. import java.util.Collections;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. Integer[] iArray = new Integer[] {101,102,103,104,105};
  7. int[] iiArray = new int[] {101,102,103,104,105};
  8. String[] sArray = new String[] {"one", "two", "three", "four", "five"};
  9. Collections.reverse(Arrays.asList(iArray));
  10. System.out.println("Arrays.toString(iArray) = " + Arrays.toString(iArray));
  11. Collections.reverse(Arrays.asList(iiArray));
  12. System.out.println("Arrays.toString(iiArray) = " + Arrays.toString(iiArray));
  13. Collections.reverse(Arrays.asList(sArray));
  14. System.out.println("Arrays.toString(sArray) = " + Arrays.toString(sArray));
  15. }
  16. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
Arrays.toString(iArray) = [105, 104, 103, 102, 101]
Arrays.toString(iiArray) = [101, 102, 103, 104, 105]
Arrays.toString(sArray) = [five, four, three, two, one]