X798: Reverse Generic Array

For this question you will be writing a method reverse that takes in two parameters.

public T[] reverse(T[] arr, T[] reversedArr)

The variable arr will be an array of items of type T. The variable reversedArr will be an empty array of type T. It will always be the same length as arr

For this assignment, populate reversedArr with the items from arr in the reversed order. Then return that reversed array.

For example, if:

int[] a = {1, 4, 9, 23, 6, 77};
int[] b = new int[6];

calling reverse(a, b) should return an array of {77, 6, 23, 9, 4, 1}

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.