How do I make the code: public static void swapArrayEnds(int[] sortArray) { int i; } flip the first and last number in? import java.util.Scanner; public class ModifyArray { public static void swapArrayEnds(int[] sortArray) { int i; } public static void main (String [] args) { Scanner scnr = new Scanner(System.in); int numElem = 4; int[] sortArray = new int[numElem]; int i; int userNum; for (i = 0; i < sortArray.length; ++i) { sortArray[i] = scnr.nextInt(); } swapArrayEnds(sortArray); for (i = 0; i < sortArray.length; ++i) { System.out.print(sortArray[i]); System.out.print(" "); } System.out.println(""); } }
How do I make the code:
public static void swapArrayEnds(int[] sortArray) {
int i;
}
flip the first and last number in?
import java.util.Scanner;
public class ModifyArray {
public static void swapArrayEnds(int[] sortArray) {
int i;
}
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
int numElem = 4;
int[] sortArray = new int[numElem];
int i;
int userNum;
for (i = 0; i < sortArray.length; ++i) {
sortArray[i] = scnr.nextInt();
}
swapArrayEnds(sortArray);
for (i = 0; i < sortArray.length; ++i) {
System.out.print(sortArray[i]);
System.out.print(" ");
}
System.out.println("");
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images