Foreach 遍历数组

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 System.out.print(w+",");

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

}
}

你可能感兴趣的:(Foreach 遍历数组)