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); }

最新文章

  1. 初试Code First(附Demo)
  2. MySQL数据库初识(二)
  3. CodeForces 148B Escape
  4. 这个好像、也许、或许、大概、应该、Maybe真的可以算是传说中的Spring.Net了吧
  5. 初始——第一款个人开发上线app store
  6. CSV工具类
  7. Python Web-第四周-Programs that Surf the Web(Using Python to Access Web Data)
  8. fasthttp中的协程池实现
  9. Redis详解(三)------ redis的五大数据类型详细用法
  10. loadrunner 参数化-如何从数据库中取数据-连接数据库进行参数化
  11. Django学习笔记之视图高级-CSV文件生成
  12. DVR登录绕过漏洞(CVE-2018-9995)
  13. A Light CNN for Deep Face Representation with Noisy Labels
  14. VMware5.5-存储
  15. BZOJ5297 [CQOI2018] 交互网络 【MatrixTree定理】
  16. Delphi实现拍照控件的程序代码
  17. python 取整
  18. xib中快捷键
  19. 【剑指Offer】俯视50题之1-10题
  20. 求助下 Ubuntu 15.10(64 位)下安装 pyspider 下的问题 - V2EX

热门文章

  1. linux笔记2.19
  2. 使用node-webkit开发Clover桌面客户端的一些记录(一)
  3. DOS头 IMAGE_DOS_HEADER
  4. vm安装不上vmtools
  5. LPC1758串口ISP下载程序
  6. IE中对于stylesheet的个数限制
  7. spark Association failed with [akka.tcp:sparkMaster@ip:7077]
  8. Sicily 1129. ISBN
  9. Entity Framework with MySQL 学习笔记一(关系)
  10. 深入理解JavaScript Hijacking原理