You are viewing a single comment's thread. Return to all comments →
Solution 1: for (int i = n - 1; i >= 0; i--) { System.out.print(arr.get(i)); if (i > 0) System.out.print(" "); }
` Solution 2:
ArrayList<Integer> newArray = new ArrayList<>(); newArray.addAll(arr); for (int i = 0; i < n; i++) { int val = newArray.remove(newArray.size()-1); arr.set(i, val); } for (Integer a : arr) { System.out.print(a +" "); }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 7: Arrays
You are viewing a single comment's thread. Return to all comments →
Solution 1: for (int i = n - 1; i >= 0; i--) { System.out.print(arr.get(i)); if (i > 0) System.out.print(" "); }
` Solution 2: