我试着用这样的循环
// ArrayList tourists
for (Tourist t : tourists) {
    if (t != null) {     
        t.setId(idForm); 
    }   
}但这并不好。有人能给我一个更好的解决方案吗?
一些有用的基准来做出更好的决定:
While loop, For loop and Iterator Performance Test
发布于 2011-01-28 01:23:38
 for (Iterator<Tourist> itr = tourists.iterator(); itr.hasNext();) {
      if (itr.next() == null) { itr.remove(); }
 }https://stackoverflow.com/questions/4819635
复制相似问题