I got small problem i got error java.lang.IndexOutOfBoundsException: Index: 29, Size: 29 when i launch this one code error is in line if ((listaSwiat != null && listaSwiat.get(x) != null) || harm.get(y).getDzienTygodnia(x + 1).equals("Nd")) but dunno why index should be 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);
for (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 like you are looping over all the elements of harm.get(y).dni and inside the loop you
do
The last time through the loop x = 28 and the size is 29. But you do
So you get the element at spot 29 which is out of bounds, because like the other answer stated the index starts at 0 not 1. You have to add a check here to see if you are currently at the last index before checking the next index.