2016年8月28日 每周一篇博客 第三周 本周没有学到什么,哀哉
List<SelectModel> options = new ArrayList<SelectModel>();
Iterator<SelectModel> iterator= options.iterator();while(iterator.hasNext()){
SelectModel model = iterator.next();
if(" a".equals(model.getText())||" b".equals(model.getText())){
iterator.remove();
}
}
iterator.next()指针 每调一次就会创建一个对象,所以需要有一个SelectModel model = iterator.next(); 去接这个iterator.next()
如果这样去写 if(" a".equals(iterator.next().getText())||" b".equals(iterator.next().getText())){
iterator.remove();
}
这样 前后将不是一个对象,iterator.next()实际是一个指针 每调一次就会创建一个对象(说了2遍)
附录一篇写的很好的博客 ,可以看看
http://blog.youkuaiyun.com/chenssy/article/details/37521461
Oracle的decode
update A set name=decode(name,null,0)+1 where id='123131'
翻译的意思 相等于if else

本文介绍了如何使用Java的ArrayList结合Iterator进行元素的遍历及删除操作,并解释了iterator.next()的作用,同时给出了一个错误示例说明为何直接在迭代中删除会导致的问题。此外,还提到了Oracle SQL中的DECODE函数用法。
1423

被折叠的 条评论
为什么被折叠?



