arraylist - java.lang.IndexOutOfBoundsException: Index: 4, Size: 4 -
how can fix outofboundsexception
?
here code using:
resultset rstagcheck = stmt.executequery( "select parking.xkrprmt.xkrprmt_pidm, parking.xkrprmt.xkrprmt_status, parking.xkrprmt.xkrprmt_expire_yr, parking.xkrprmt.xkrprmt_tag parking.xkrprmt xkrprmt_pidm ='" + bannerid + "'"); while (rstagcheck.next()){ string tagnum = rstagcheck.getstring("xkrprmt_tag"); arraylist<string> mytag = new arraylist<string>(); (int = 0; < tagnum.length(); i++){ mytag.add(tagnum); mytag.get(i + i);
i kinda know why getting error, not sure how remedy problem.
what expect mytag.get(i + i)
do?
the first time through loop, "i" 0 , add 1 element. there won't element 1, call throw exception. see wrote, it'll fail on second iteration, not first, poor @giu noted in now-deleted answer. still, it's weird , don't know you're trying accomplish calling .get()
, not looking @ return value.
you have explain you're trying do, because doesn't make sense written. did exception in question title really come code, or did edit part of out when posting?
edit — whoops totally saw "i+i" "i+1". still makes no sense me however.
Comments
Post a Comment