Question: import java.util.Arrays; /* * * This program takes an array of integers, reverses the elements and stores them in a new array * */ public

import java.util.Arrays;

/*

*

* This program takes an array of integers, reverses the elements and stores them in a new array

*

*/

public class ReverseElements

{

/**

Reverses an array.

@param data - the input array

@return an array with the elements of data in reverse order

*/

public static int[] reverse(int[] data)

{

//-----------Start below here. To do: approximate lines of code = 6

//

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

public static void main(String[] args)

{

int[] data = { 1, 4, 9, 16, 9, 7, 4, 9, 11 };

int[] reversed = reverse(data);

for (int i = 0; i < reversed.length; i++)

{

System.out.print(reversed[i] + " ");

}

System.out.println();

System.out.println("Expected: 11 9 4 7 9 16 9 4 1");

}

}

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!