I’m trying to make a table starting from a map with a list as value. Each list has 2 Strings in them
public class Table{
public static PdfPTable createTable( HashMap<Integer,List<String>> map ){
PdfPTable table = new PdfPTable(2); // 2 is the number of columns
for( int i = 1 ; i == map.size() ; i++ ){
PdfPCell leftCell = new PdfPCell(new Paragraph(map.get(i).get(0)));
PdfPCell rightCell = new PdfPCell(new Paragraph(map.get(i).get(1)));
table.addCell( leftCell );
table.addCell( rightCell );
}
return table;
}
}
I’m sure the data is in the map, but it seems that the table is empty. Any suggestions?
Your for loop is incorrect:
What you want