in the above code you stored array with five elements so yor index range from 0 to 4
you mention i=1 and maxmium is 5
so for iterations i become 5 at that time it will give arrayoutbound exception
you can just change
sorry but you solution didnt work,
there is problem in in this statement a[i]>a[i+1] ,when i be 5 ,it is in a>a, so compiler search for a and dont found,so here gave me the problem ,and by the way what is a[i]>a[i+1] i didnt get it
iknow that but i want to sort array as the code show but compiler when a[i] reach the final one a it compare it with a which it is not exist , i want to it stop compare when it reach the final index is there any code that could help me???
1) IF you store just one object, use List, if you have two object key and value use Map.
2) List is ordered, your objects will be stored in the order on which they are inserted, Map is not ordered, unless you use sorted ones.