Question: Flip itGiven the instantiated Array called arr and the variable size which stores the value for how many elements are in the Array, do the

Flip itGiven the instantiated Array called arr and the variable size which stores the value for how many elements are in the Array, do the following:
Write code that will flip the elements in the Array arr to reverse order.
Print the elements to the console on one line with a space between each element.
This can be done two ways, and should be completed whatever way makes the most sense.
The Instructor Solution will have two ways of accomplishing this task, one will be commented out.
import java.io.*;
import java.util.*;
public class CodingQuestion {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int size = in.nextInt(); in.nextLine();
String[] arr = new String[size];
for (int i =0; i < size; i++){
arr[i]= in.nextLine();
}
System.out.println("Original array:");
for(int i =0; i
STDOUT
Expected STDOUT
Originalarray:
programmingloveI
Reversedarray:
Iloveprogramming

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 Programming Questions!