The array size is 5 but at below loop for max value of i
you are incrementing it by 1, and so trying to access array[5]
(array[4+1]
), which causes your ArrayIndexOutOfBoundsException
.
for(int i=0;i < 5;i++)
{
if(array[i] > array[i+1])
--------------------------------------^
maxt = array[i];
}