I'm trying to call a method that prints the first and third quartiles of a data set (array of doubles), and to do that it needs to check whether or not the array of doubles has been sorted (using Array.sort() ). To check if the array has been sorted, I use static boolean isSorted(double[] data).
On the line containing the if-statement, I get the ArrayIndexOutOfBoundsException, when running the driver program. Any ideas as to how to fix this?Code:static boolean isSorted(double[] data) { int biggerCount = 0; for(int m = 0; m<data.length;m++) { if(data[m] != Math.min(data[m], data[m+1]) ) biggerCount++; else{} } if(biggerCount == 0) return true; else return false; }


Reply With Quote
Bookmarks