Question: Is there a way to reverse this array as I have tried? import java.util.Scanner; import java.util.ArrayList; public class Arrays { public static void main(String[]args) {

Is there a way to reverse this array as I have tried?

import java.util.Scanner; import java.util.ArrayList; public class Arrays { public static void main(String[]args) { int [] aList = new [] userInput() System.out.println(userInput()); reverseList(aList); } public static ArrayList userInput() { Scanner in = new Scanner(System.in); ArrayList array = new ArrayList(); System.out.println("enter 5 integers"); for (int j = 0; j < 5; j++) { int input = in.nextInt(); array.add(input); } return array; } public static void reverseList(int[] list) { for (int i = list.length - 1; i >= 0; i--) { System.out.println(list); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!