hahaha that was funny I knew the problem was with your nested loops, I was thinking Why do i need an nested look with an array because they are basically a linear set, normally you can use nested loops to work with Matrices but I figure that removing one of the loops would work so heres the right way...
public void computeMode() { for (modeLookUp1 = 0; modeLookUp1 < size; modeLookUp1++) { incidences = 0; for (modeLookUp2 = 0; modeLookUp2 < size; modeLookUp2++) { if (list[modeLookUp2] == list[modeLookUp1]) incidences++; } if (incidences > maxIncidences) { maxIncidences = incidences; mode = list[modeLookUp1]; } } }
I didn't remove the found loop because it was already in the class that he created (didn't want to mess with that). I assumed you were using it for another method, but the while loop is entirely unneeded. Unless you were to physically write the for-loops as while-loops, you don't need the found boolean. From what I can see the innards have remained unchanged?