Java List 遍历

  

  //方法1

  Iterator it1 = list.iterator();

  while(it1.hasNext()){

  System.out.println(it1.next());

  }

  //方法2 

  for(Iterator it2 = list.iterator();it2.hasNext();){

  System.out.println(it2.next());

  }

  //方法3

  for(String tmp:list){

  System.out.println(tmp);

  }

  //方法4

  for(int i = 0;i < list.size(); i ++){

  System.out.println(list.get(i));

  }

  }

  }

posted @ 2013-11-08 15:28  一个学渣  阅读(124)  评论(0编辑  收藏  举报

 

CSDNGitHub 联系邮箱:aikongmeng@gmail.com


Copyright 2008-2019 Government All Rights Reserved