arrays - Java arraylist outofbounds -


i know question has been asked million times. , feel solution obvious hasn't been staring @ couple of hours. can't make head or tails of out of bound exception. here error:

exception in thread "main" java.lang.indexoutofboundsexception: index: 207493, size: 207493     @ java.util.arraylist.rangecheck(arraylist.java:604)     @ java.util.arraylist.get(arraylist.java:382)     @ affysureselect.affysureselect.main(affysureselect.java:92) java result: 1 

i thinking perhaps might happening due size of arraylist, if case have expected error when adding, rather getting. here code dying:

    string chrompos;     arraylist<string> chromnum = new arraylist<string>();     while ((input2 = sbuff.readline()) != null) {         prse = input2.split("\t");         chromnum.add(prse[0]);         ...         chrompos = prse[7];      }     int cnt = 0;     int cnt2 = 0;     if (chromnum.get(cnt).equals(chrompos)) { // line causing untimely death       end = integer.parseint(chromposend.get(cnt2));       start = integer.parseint(chromposstart.get(cnt2));        ... 

i tried adding:

if (cnt <= chromnum.size()) { //this line   if (chromnum.get(cnt).equals(chrompos)) { /before dying line 

but dies anyway, on get, not add. missing?

if incrementing cnt, make sure it's less chromnum.size().

it should be-

if (cnt < chromnum.size()) 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -