concatenate two outputs for each or make them into one java

0

Consultation I have two foreach each of 81 records

        listat = personNE.list();
        listap = parametrosEspNE.list();  


        for(ParametrosEsp pe : listap ){
           pw.prinln(String.valueOf(pe.getVALOR()+"|")); 

             }
        for(Person p : listat){         

               pw.prinln(String.valueOf(p.getCODIGO_DOC()+"|"+p.getCEDULA()+"|"+"1"+"|"));

        }

When I put the key under it it repeats me 81 times, and then again 81 How can I solve or concatenate the two print but in order?

The result shows me this way:

| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
| 1.23 |
01 | 912358342 ||
01 | 912358353 ||
01 | 912358321 ||
01 | 912358213 ||
01 | 912358344 ||
01 | 912432333 ||
01 | 912358345 ||
01 | 912358346 ||
01 | 912358376 ||
01 | 234324344 ||
01 | 423432432 ||
01 | 423545466 ||

and I want it to come out like this

| 1.23 | 01 | 912358342 ||
| 1.23 | 01 | 912358353 ||
| 1.23 | 01 | 912358321 ||
| 1.23 | 01 | 912358344 ||
| 1.23 | 01 | 912432333 ||
| 1.23 | 01 | 912358345 ||
| 1.23 | 01 | 912358346 ||
| 1.23 | 01 | 912358376 ||
| 1.23 | 01 | 234324344 ||
| 1.23 | 01 | 423432432 ||
| 1.23 | 01 | 423545466 ||

    
asked by Dalstron 15.11.2018 в 18:58
source

1 answer

0

I think your only solution is to use a for loop

listat = personNE.list();
listap = parametrosEspNE.list(); 

if (listat.size() == listap.size()){
  int iteraciones = listat.size();

  for(int i = 0; i < iteraciones; i++) {
    pw.println(
      String.valueOf(listap.get(i).getVALOR()+"|") + 
      String.valueOf(listat.get(i).getCODIGO_DOC() + "|"+listat.get(i).getCEDULA()+"|"+"1"+"|")
    );
  }
}
    
answered by 15.11.2018 / 22:20
source