set遍历
来源:互联网 发布:对网络教育的看法英语 编辑:程序博客网 时间:2024/06/02 21:32
对 <span style="background-color: rgb(153, 255, 153);">set</span> 的<span style="background-color: rgb(160, 255, 255);">遍历</span>1.迭代<span style="background-color: rgb(160, 255, 255);">遍历</span>:<span style="background-color: rgb(153, 255, 153);">Set</span><String> <span style="background-color: rgb(153, 255, 153);">set</span> = new HashSet<String>();Iterator<String> it = <span style="background-color: rgb(153, 255, 153);">set</span>.iterator();while (it.hasNext()) { String str = it.next(); System.out.println(str);}2.for循环<span style="background-color: rgb(160, 255, 255);">遍历</span>:for (String str : <span style="background-color: rgb(153, 255, 153);">set</span>) { System.out.println(str);}优点还体现在泛型 假如 <span style="background-color: rgb(153, 255, 153);">set</span>中存放的是Object<span style="background-color: rgb(153, 255, 153);">Set</span><Object> <span style="background-color: rgb(153, 255, 153);">set</span> = new HashSet<Object>();for循环<span style="background-color: rgb(160, 255, 255);">遍历</span>:for (Object obj: <span style="background-color: rgb(153, 255, 153);">set</span>) { if(obj instanceof Integer){ int aa= (Integer)obj; }else if(obj instanceof String){ String aa = (String)obj } ........}
0 0
- 遍历set
- set 遍历
- 遍历set
- set遍历
- 遍历set
- 遍历set
- Set遍历
- 遍历Set
- 使用循环遍历Set
- Set的循环遍历
- Set的遍历
- java遍历set
- java 遍历set集合
- java Set 遍历
- java遍历Set集合
- Java遍历Set集合
- java遍历Set集合
- Java遍历Set集合
- java内存溢出和内存泄露
- 集团信息化之路 为电子采购系统申请域名并进行备案
- Android 平台 tess-two 图像识别 环境搭建
- hdu 2665 Kth number(函数化线段树)
- Android打造通用的下拉刷新组件
- set遍历
- (算法设计技巧与分析)floyd
- php 函数
- MSSQL数据库导入导出时错误 0xc0202049: 数据流任务 1: 无法在只读列“ID”中插入数据
- CserialPort类函数解析及基本操作流程 基于C++
- Spring学习_03_AOP在Spring中的两种实现方式
- 寒假集训——Index of super-prime 和 北航9届校赛晴天小猪爱61
- Oracle EBS:PO 常用的查询及Tips
- 数据存储大小端