I am having error in the following code. What should I do to fix it? Also, how should I call it in main method to test the code? please HELP :(
package sortingelements;
public class Main {
public static void main(String[] args) {
}
public int indexOfMaxInRange (int[] myArray, int begin, int end) {
int index = -999;
int maxInRange = -999;
for (int i = begin; i < end; i++) {
int temp = myArray[i];
if (temp >= maxInRange) {
index = i;
maxInRange = temp;
}
}
return index;
}
public void swapElement (int[] myArray, int first, int second) {
int temp = myArray[first];
myArray[first] = myArray[second];
myArray[second] = temp;
}
public void sortArray (int[] myArray) {
for (int i = 0; i < myArray.length; i++) {
int index = indexOfMaxInRange (i, myArray.length);
swapElement (myArray, index, i);
}
}
}