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");
}
}
P.S: Please write the code as well as include screenshots for reference along with output
Step by Step Solution
3.40 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
import javautilArrays This program takes an array of integers reverses the e...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Data Structures and Algorithms in Java
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
6th edition
1118771334, 1118771338, 978-1118771334
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App