这种写法是不正确的,会报java.util.NoSuchElementException的错误。iterator.next()不能连续用,这个为什么
Iterator iterator = list.iterator();
while(iterator.hasNext()){
if(iterator.next().getCompanycode()==null){
error.append("接口表中Companycode的必录项有空,");
}
else if(iterator.next().getSalechannelcode()==null){
error.append("接口表中Salechannelcode的必录项有空,");
}
if(iterator.next().getBillnumber()==null){
error.append("接口表中Billnumber的必录项有空,");
}
if(iterator.next().getBillbooknumber()==null){
error.append("接口表中Billbooknumber的必录项有空,");
}
if(iterator.next().getSeragentcode()==null){
error.append("接口表中Seragentcode的必录项有空,");
}
if(iterator.next().getPhone()==null){
error.append("接口表中Phone的必录项有空,");
}
if(iterator.next().getSersectioncode()==null){
error.append("接口表中Sersectioncode的必录项有空,");
}
if(iterator.next().getSerteamcode()==null){
error.append("接口表中Serteamcode的必录项有空,");
}
if(iterator.next().getPolicyholdername()==null){
error.append("接口表中Policyholdername的必录项有空,");
}
if(iterator.next().getInsurecode()==null){
error.append("接口表中Insurecode的必录项有空,");
}
if(iterator.next().getCerttypecode()==null){
error.append("接口表中Certtypecode的必录项有空,");
}
if(iterator.next().getChargetypecode()==2&&iterator.next().getBankcode()==null){
error.append("CHARGETYPECODE=2转帐时,BANKCODE不能为空,");
}
if(iterator.next().getChargetypecode()==2&&iterator.next().getAccountname()==null){
error.append("CHARGETYPECODE=2转帐时,Accountname不能为空,");
}
if(iterator.next().getChargetypecode()==2&&iterator.next().getAccounts()==null){
error.append("CHARGETYPECODE=2转帐时,Accounts不能为空,");
}
if(iterator.next().getChargetype()==3&&iterator.next().getPeriodofvalidity()==null){
error.append("ChargeType为信用卡时,PERIODOFVALIDITY, 信用卡缴费不能为空,");
}
if(iterator.next().getChargetype()==3&&iterator.next().getPeriodofvalidity().matches("^\\d{4}$")){
error.append("ChargeType为信用卡时,信用卡有效期至 格式不正确,");
}
if (iterator.next().getChargetype()==3//中信信用卡转帐时,Ensuremodel,计划型号必录
&&iterator.next().getBrushbankcode().equals("017")
&&iterator.next().getEnsuremodel()==null){
error.append("中信信用卡转帐时,Ensuremodel,计划型号不能为空");
}