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 mainString args
Scanner in new ScannerSystemin;
int size innextInt; innextLine;
String arr new Stringsize;
for int i ; i size; i
arri innextLine;
System.out.printlnOriginal array:";
forint i ; 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
