I have completed the requirements, but it still fails. I don't know what I have missed. I would return the new array if the assignment would let me do such a thing but I have to change the original array and that is what I believe I have done. I believe it may be the commas after the last element when I run my code. However that is handled by printArray and I should not have to touch that.
package en.codegym.task.pro.task06.task0605;
/*
Correct order
*/
public class Solution {
public static void main(String[] args) {
int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
printArray(array);
reverseArray(array);
printArray(array);
}
public static void reverseArray(int[] array) {
//write your code here
int[] newArray = new int[10];
for (int i = 0; i < array.length; i++) newArray[i] = array[9 - i];
for (int i = 0; i < array.length; i++)
array[i] = newArray[i];
}
public static void printArray(int[] array) {
for (int i : array) {
System.out.print(i + ", ");
}
System.out.println();
}
}