Foreach 遍历数组

2016-10-27  本文已影响0人  明明的故事

public class Foreach {
public static void main(String[] args) {
int arr[]=new int[2];
String ssr[]=new String[]{"sf","df"};
arr[0]=1;
arr[1]=2;
for(int w: arr){ //foreach 遍历数组 比for(int i=0;i<ssr.lenth;i++) 来的快一些
System.out.print(w+",");

}
System.out.println();
for(String o:ssr){
    System.out.print(o+"、");
    
}

}
}

上一篇 下一篇

猜你喜欢

热点阅读