for ( int i=0 ; i<=list.size() ; i++){
....}
By executing this for loop , the loop will execute with a thrown exception as IndexOutOfBoundException
cause, suppose list size is 10 , so when index i will get to 10 i.e when i=10 the exception will be thrown cause index=size
, i.e. i=size
and as known that Java considers index starting from 0,1,2...etc the expression which Java agrees upon is index < size
. So the solution for such exception is to make the statement in loop as i<list.size()
for ( int i=0 ; i<list.size() ; i++){
...}