java - IndexOutofBoundException why? -


i got small problem got error java.lang.indexoutofboundsexception: index: 29, size: 29 when launch 1 code error in line if ((listaswiat != null && listaswiat.get(x) != null) || harm.get(y).getdzientygodnia(x + 1).equals("nd")) dunno why index should 30 not 29 any1 can help?

for (int y = 0; y < harm.size(); y++) {//wiersze             c1 = new pdfpcell(new phrase(harm.get(y).nazwa, stdfont));             c1.sethorizontalalignment(element.align_center);             table.addcell(c1);             c1 = new pdfpcell(new phrase("" + harm.get(y).getsumagodzin() + " / " + harm.get(y).normagodzin, smallfont));             c1.sethorizontalalignment(element.align_center);             table.addcell(c1);             (int x = 0; x < harm.get(y).dni.size(); x++) {//kolumny                 c1 = new pdfpcell(new phrase(harm.get(y).dni.get(x).godziny, smallfont));                 //dla swiąt ustal kolor tła na czerwono                 //dla niedziel ustala kolor tla na czerwony                 if ((listaswiat != null && listaswiat.get(x) != null) || harm.get(y).getdzientygodnia(x + 1).equals("nd")) {                     c1.setbackgroundcolor(basecolor.red);                 } 

it looks looping on elements of harm.get(y).dni , inside loop do

if ((listaswiat != null && listaswiat.get(x) != null)  || harm.get(y).getdzientygodnia(x + 1).equals("nd")) 

the last time through loop x = 28 , size 29. do

harm.get(y).getdzientygodnia(x + 1) 

so element @ spot 29 out of bounds, because other answer stated index starts @ 0 not 1. have add check here see if @ last index before checking next index.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -