java - index out of bounds error why? -
the line x.set(7,y)
in code below throwing indexoutofboundsexception
, , can't figure out why. can help?
linkedlist<myclass> x = new linkedlist<myclass>(); x = myarraylist.get(7); iterator<myclass> itr = x.iterator(); myclass y = new myclass(); while (itr.hasnext()) { y = itr.next(); if (z.methodcalltogetstr().equals(y.methodcalltogetstr()))//z myclass object { y.inccount(); x.set(7, y); break;
assuming myarraylist.get(7) creates 7 elements, these elements numbered 0 6. 7th 1 off end of list.