您的位置:首页 > 其它

foreach方式输出集合

2016-07-14 09:47 148 查看
foreach输出格式:

for(类  对象  :  集合){

//对对象的操作

}

import java.util.ArrayList; 

import java.util.List; 

public class ForeachDemo01{
public static void main(String args[]){
List<String> all = new ArrayList<String>() ;
all.add("hello") ;
all.add("_") ;
all.add("world") ;
for(String str:all){
System.out.print(str + "、") ;
}
}
};

运行结果:

hello、_、world、
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  foreach