Question: The template code below is supposed to return a new array, where the resulting array contains the elements in original, but reversed. The following examples

The template code below is supposed to return a new array, where the resulting array contains the elements in original, but reversed. The following examples illustrate this behavior:

  • reverseArray(new int[]{}) returns new int[]{}
  • reverseArray(new int[]{1}) returns new int[]{1}
  • reverseArray(new int[]{1, 2}) returns new int[]{2, 1}
  • reverseArray(new int[]{1, 2, 3}) returns new int[]{3, 2, 1}

The signature of reverseArray has been provided below. Finish implementing the reverseArray method.

public static int[] reverseArray(int[] original) { ... }

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!