public class selectionSort{ public static void main(String[]args){ double[] array = {1, 9, 4.5, 6.6, 5.7,}; selectionSort(array); } public static void selectionSort(double[]array){ for (int i =0; i<array.length-1; i++){ double min = array[i]; int minIndex = i; for (int j = i+1; i<array.length; i++){ if ( min> array[i]) array[i]= min; } if ( minIndex!=i){ array[minIndex]= array[i]; array[i]= min; } } } }
ok SO I am still trying to learn arrays, the thing is that I keep getting these error! I do not know WHAT i AM DOING WRONG!
THE ERROR IS THE FOLLOWING!
----jGRASP exec: java selectionSort
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at selectionSort.selectionSort(selectionSort.java:25)
at selectionSort.main(selectionSort.java:6)
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
can somenoe explain it to me?
thanks!