Good evening everyone. I'm working my way through this and have hit a block in regards to using a class inside another class. Eclipse informs me that the error is a result of trying to call a static reference to a non-static method. All I am trying to do is use the method "reverse" multiple times in one program. I know that the issue is in the "reverse" class, and am looking to find the correct way format the class to accept input from the code in the main method.
public static void main (String [] args){
//creating a test array
int [] myArray = {0, 1, 2, 3, 4, 5, 6,7 ,8 ,9};
int [] myArrRev = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
reverse (myArray);
if ( Arrays.equals(myArray, myArrRev))
System.out.println("reverse worked for 10 elements.");
int [] myArray2 = {0, 1, 2, 3, 4, 5, 6,7 ,8};
int [] myArrRev2 = { 8, 7, 6, 5, 4, 3, 2, 1, 0};
reverse (myArray2);
if ( Arrays.equals(myArray2, myArrRev2))
System.out.println("reverse worked for 9 elements.");
int [] myArray3 = {0};
int [] myArrRev3 = {0};
reverse (myArray3);
if ( Arrays.equals(myArray3, myArrRev3))
System.out.println("reverse worked for 1 element.");
int [] myArray4 = {};
int [] myArrRev4 = {};
reverse (myArray4);
if ( Arrays.equals(myArray4, myArrRev4))
System.out.println("reverse worked for 0 elements.");
}
void reverse( int arr[] ){
for(int i = 0; i < arr.length / 2; i++)
{
int temp = arr[i];
arr[i] = arr[arr.length - i - 1];
arr[arr.length - i - 1] = temp;
}
}
}