数组
来源:互联网 发布:mac怎么连打印机 编辑:程序博客网 时间:2024/05/16 12:04
poll 和remove 方法:
都是从集合取出一个元素,如果为空,poll 会返回null;
remove 会报异常
Arrays工具类 toString 输出数组内容。。。
list 删除问题:
三种错误:爆出ConcurrentModificationException
for(object:list)
{
if()
list.remove(object)
}
for(index;index<list.size();index++)
if();
list.remove(list[index]);
数据遗落,在remove后 索引变化。比如2取出 3就是2了;
解决方案:对用size() 使用下标遍历;
或者如下 iterate;
iterate it=list.iterate;
if(it.hasenext())
list.remove();
都是从集合取出一个元素,如果为空,poll 会返回null;
remove 会报异常
Arrays工具类 toString 输出数组内容。。。
list 删除问题:
三种错误:爆出ConcurrentModificationException
for(object:list)
{
if()
list.remove(object)
}
for(index;index<list.size();index++)
if();
list.remove(list[index]);
数据遗落,在remove后 索引变化。比如2取出 3就是2了;
解决方案:对用size() 使用下标遍历;
或者如下 iterate;
iterate it=list.iterate;
if(it.hasenext())
list.remove();
阅读全文
0 0
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- 数组
- MySQL比like语句更高效的写法locate position instr find_in_set
- Spark Streaming 流计算优化记录(2)-不同时间片数据流的Join
- [技术人生]在你步入职业软件开发生涯那天起就该知道的五件事
- Windows文件换行符转Linux换行符
- Anbox 容器管理服务
- 数组
- fastjson SerializerFeature详解
- PHPMailer发送邮件中的坑
- servlet中请求转发(forward)与重定向(sendredirect)的区别
- Spark Streaming 流计算优化记录(3)-控制流量与join的地点
- PAT1006. Sign In and Sign Out (25)
- 解决服务器连接错误Host ‘XXX’ is not allowed to connect to this MySQL server
- Android 自定义节点流程View
- 正则表达式