当我调试我的代码时,我发现返回的hasNext()
方法,但是该方法抛出了 NoSuchElementException。Iterator
true
next()
下面是我的代码:
Collection<TradeStock> restBuy=em.createQuery("select t from TradeStock ...t.getResultList();
if(!restBuy.isEmpty())
{
Iterator itrest=restBuy.iterator();
while(itrest.hasNext())
{
TradeStock ts=(TradeStock)itrest.next();
x+=ts.getTradeExecutedQuantity();
}
}
我怎么了?