Sorting Arrays with JBuilder
Its late and I am baffled once more. I am wondering what ever possesed me to take this Java programming course online, but here it is.
The example that was given has a list of 8 numbers (2, 9, 8, 7, 5, 4, 6, 1) and used the maximum number and swapped it to the last position, I need to take the smallest number and place it in the first position.
I thought it would be no problem but I was wrong; I am getting a nosuchmethoderror:main when I attempt to run the program.
package selectionSort;
public class SelectionSort {
/**The method for sorting the numbers*/
public static void selectionSort(double[] list) {
for (int i = list.length-1; i >= 1; i--) {
//Find the minimun in the list [0....i]
double currentMin = list[0];
int currentMinIndex = 0;
for (int j = 1; j >= i; j--){
if (currentMin < list [j]) {
currentMin = list [j];
currentMinIndex = j;
}
}
//Swap list [i] with list [currentMinIndex] if necessary
if (currentMinIndex != i) {
list [currentMinIndex] = list [i];
list [i] = currentMin;
}
}
}
}
I know the error usually indicates that there is a mispelling in the main method, or no main method found. But the public class and public static void statements are exactly as in the book. What am I not getting?
Also, will did give the desired result?
Thanks in advance
|