Question: Java You will be creating a single class: ArrayMethods Create a single instance variable for an array of size 10, call this values. The construtor:
Java
You will be creating a single class: ArrayMethods
Create a single instance variable for an array of size 10, call this values.
The construtor:
will construct the array and initialize it to the values: 1 through 10
[1,2,3,4,5,6,7,8,9,10]
You will create the following methods:
1) swapFirstLast
this will swap the first and the last elements of the array
2) shiftRight
this will shift all elements to the right by one and move the last element to the first position
3) replaceEven
this will replace all elements conatining an even value with the value 0
4) replaceNeighbor
this will replace each element, except the first and the last, by the larger of its two neighbors.
All of the methods above(1-4) MUST work for any size array!
5) printArray
this will simply print the array to the terminal
your main method
will call each of the methods 1 through 4 above in order. After every method call, print a proper label and call the printArray method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
