for(int i = 0; i<listut.size();i+=2){
String query3="select........";
ResultSet rs3= con.createStatement().executeQuery(query3);
while(rs3.next())
{
idserv= rs3.getString("IDservices");
nameserv= rs3.getString("Name");
autorizzato = rs3.getString("Autorizzato");
listab.add(idserv);
listab.add(nameserv);
listab.add(autorizzato);
}}
我对arraylist的输出有问题,结果重复了,在arraylist listut中,我每个元素都有3个元素。 第一个元素:
[1, getStructureAgent, 1, 2, searchStructureAgent, 0, 3, getZona, 0, 4, getFido, 0, 5, getCostruttore, 0, 6, searchAgent, 0, 7, getPayment, 0, 8, searchGruppo, 0, 9, getArticolo, 0, 10, searchPayment, 0, 11, searchZona, 0, 12, getGruppo, 0, 13, getCustomers, 0, 14, searchArticolo, 0, 15, getSottoGruppo, 0, 16, getAgent, 0, 17, getCustomer, 0, 18, searchCondizioniBancarieClienteOasi, 0, 19, getArboAnagrafica, 0, 20, getFidoClienteOasi, 0, 21, searchSottoGruppo, 0, 22, searchCostruttore, 0]
第二个元素
[1, getStructureAgent, 1, 2, searchStructureAgent, 0, 3, getZona, 0, 4, getFido, 0, 5, getCostruttore, 0, 6, searchAgent, 0, 7, getPayment, 0, 8, searchGruppo, 0, 9, getArticolo, 0, 10, searchPayment, 0, 11, searchZona, 0, 12, getGruppo, 0, 13, getCustomers, 0, 14, searchArticolo, 0, 15, getSottoGruppo, 0, 16, getAgent, 0, 17, getCustomer, 0, 18, searchCondizioniBancarieClienteOasi, 0, 19, getArboAnagrafica, 0, 20, getFidoClienteOasi, 0, 21, searchSottoGruppo, 0, 22, searchCostruttore, 0, 1, getStructureAgent, 1, 2, searchStructureAgent, 0, 3, getZona, 0, 4, getFido, 0, 5, getCostruttore, 0, 6, searchAgent, 0, 7, getPayment, 0, 8, searchGruppo, 0, 9, getArticolo, 0, 10, searchPayment, 0, 11, searchZona, 0, 12, getGruppo, 0, 13, getCustomers, 0, 14, searchArticolo, 0, 15, getSottoGruppo, 0, 16, getAgent, 0, 17, getCustomer, 0, 18, searchCondizioniBancarieClienteOasi, 0, 19, getArboAnagrafica, 0, 20, getFidoClienteOasi, 0, 21, searchSottoGruppo, 0, 22, searchCostruttore, 0]
在第二个cicle中,数组包含第一个cicle的结果
答案 0 :(得分:0)
如果您希望listab
将for循环的每个迭代开始为空,则需要在该循环的主体顶部使其为空。