mercredi 15 juillet 2015

Populate List w/ data

I have this code. The first for is to change line and the second for is to fill each line. With the first for I want to read the data from data[] and put it in different lines.

    List lista = new ArrayList();
    Bean line = new Bean();

    int j;
    int i;

    for (j = 1; j < data.length; j++) {
        LinkedHashMap<String, Object> hmap = (LinkedHashMap<String, Object>)data[j];

        for (i = 1; i < headers.length; i++) {
            line.choosefield(i,headers,hmap);
            }
        lista.add(line);
    }

I'm basically just getting the last line of my data[] repeated over and over. I think I could do something like

lista.add(line1,2,3...)

How can I do this and is there a better way? Using JDK 16. Thanks.





Aucun commentaire:

Enregistrer un commentaire