am new to java and facing problem with arraylist , i do not know whats wrong with my "for loop" am unable to exit it , producing error it end
ArrayList<String> r2 = new ArrayList<String>();
for(int i=0; i<= idx.length; i++) {
ArrayList<String> r = db.Fetch(idx[i],exta);
if(r.size() != 0) {
for (String s : r) {
r2.add(s);
Log.d("test","ID "+idx[i]+ " :" + s);
}
}
}
When i run it i get correct values printed on Log.d but the loop not exit it end so help
idx? Also, the innerfor-loop seems to be correct.for(int i=0; i<idx.length; i++). Since the for-loop starts at 0, you can't access an element at location X if the size of the ArrayList. The way your code is build up right now, you'll run into an ArrayOutOfBoundsException...