Question: slove CHALLENGE ACTIVITY 9.5.1: Modify an array parameter. Write a method swapArrayEnds() that swaps the first and last elements of its array parameter. Ex: sortArray
slove
CHALLENGE ACTIVITY 9.5.1: Modify an array parameter. Write a method swapArrayEnds() that swaps the first and last elements of its array parameter. Ex: sortArray = {10, 20, 30, 40} becomes (40, 20, 30, 10}. The array's size may differ from 4. Learn how our autograder works 686470.5454358.qx3zqy7 1 import java . util. Scanner; 1 test passed N 3 public class ModifyArray { All tests 5 V* Your solution goes here */ passed public static void main (String args) { 8 int numElem = 4; 9 int sortArray = new int [numElem]; 10 int i = 0; 11 12 sortArray [0 ] = 10; 13 sortArray [ 1 ] = 20; 14 sortArray [ 2 ] = 30; 15 sortArray [ 3 ] = 40; 16 17 swapArrayEnds (sortArray, numElem)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
