ArrayList IndexOutOfBoundException JSP -


i taking 12 records database , storing in resultset since cannot fetch each element resultset whereever want. using arraylist store resultset data , using arraylist.get() method retrieve each element.

but problem data coming database can less 12 records have accessed arraylist.get(12) throws indexoutofboundexception. want check whether array.get(12)th element out of bound or not before printing value of it.

i have tried if(arraylist.get(12)!=null) doesn't work because again trying access 12th record not exist in arraylist.

if list contains 12 items , want last one, have use .get(11), since lists, arrays, sets, etc., 0-based indexed in java. on other hand, if want first one, have use .get(0) instead of .get(1) (which returns second one).


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -