list类型for遍历
2024-09-02 05:02:06
package cn.stat.p9.map.demo; import java.util.ArrayList; public class Listfor { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<String> al=new ArrayList<String>();
al.add("asdf");
al.add("qwer");
al.add("zxcv");
al.add("yuio"); for(String s : al)
{
System.out.println(s);
} } }
foreach语句格式
for(类型 变量 :Collection集合或数组
{
}
//foreach 遍历map集合,要先转成单列的set
Map<Integer,String> al=new TreeMap<Integer,String>();
al.put(12,"asdf");
al.put(32,"qwer");
al.put(65,"zxcv");
al.put(10,"yuio"); for(Integer key : al.keySet())
{
String value=al.get(key);
System.out.println("key="+value);
} for(Map.Entry<Integer, String> me : al.entrySet())
{
Integer key =me.getKey();
String value=me.getValue();
System.out.println(key+" "+value); }
最新文章
- 初试Code First(附Demo)
- MySQL数据库初识(二)
- CodeForces 148B Escape
- 这个好像、也许、或许、大概、应该、Maybe真的可以算是传说中的Spring.Net了吧
- 初始——第一款个人开发上线app store
- CSV工具类
- Python Web-第四周-Programs that Surf the Web(Using Python to Access Web Data)
- fasthttp中的协程池实现
- Redis详解(三)------ redis的五大数据类型详细用法
- loadrunner 参数化-如何从数据库中取数据-连接数据库进行参数化
- Django学习笔记之视图高级-CSV文件生成
- DVR登录绕过漏洞(CVE-2018-9995)
- A Light CNN for Deep Face Representation with Noisy Labels
- VMware5.5-存储
- BZOJ5297 [CQOI2018] 交互网络 【MatrixTree定理】
- Delphi实现拍照控件的程序代码
- python 取整
- xib中快捷键
- 【剑指Offer】俯视50题之1-10题
- 求助下 Ubuntu 15.10(64 位)下安装 pyspider 下的问题 - V2EX
热门文章
- linux笔记2.19
- 使用node-webkit开发Clover桌面客户端的一些记录(一)
- DOS头 IMAGE_DOS_HEADER
- vm安装不上vmtools
- LPC1758串口ISP下载程序
- IE中对于stylesheet的个数限制
- spark Association failed with [akka.tcp:sparkMaster@ip:7077]
- Sicily 1129. ISBN
- Entity Framework with MySQL 学习笔记一(关系)
- 深入理解JavaScript Hijacking原理