我想获取List
中特定对象的计数AgentSumBeans obj=new AgentSumBeans();
while(rs.next())
{
obj.setIrctcIdCreatedDate(rs.getString(1));
obj.setIsevaProOpted(rs.getString(2));
}
list.add(obj);// first object
AgentSumBeans obj2=null;
while(rs3.next())
{
obj2=new AgentSumBeans();
obj2.setAmonthyear(rs3.getString(1));
obj2.setAnoOfTkts(rs3.getInt(2));
obj2.setAbookingAmount(rs3.getInt(3));
obj2.setAavgAmount(rs3.getInt(4));
obj2.setAperDayTkts(rs3.getInt(5));
list.add(obj2);// i will be getting more than one object here
}
如何查找创建了多少obj2
个对象?
答案 0 :(得分:1)
尝试用计数器替换while
循环到for
循环 - 我认为这是最简单的解决方案。
或者在while
循环之前创建计数器。