- 定义一个静态的二维数组,并用2种循环语句给输出
public class HelloWorld {
public static void main(String[] args){
int data [][] = new int [][] {
{1,2,3,4,5},{4,5,6} , {7,8,9,10}
};
for (int x = 0;x < data.length ; x++){
for(int y = 0;y < data[x].length ; y++){
System.out.println("data[" + x + "][" + y + "] = " + data[x][y]);
}
}
// 开发中实际很少用到二维数组----可能都是用集合处理了;二维数组不用当作重点
System.out.println("------------");
for(int temp[] : data){// 这里temp 是数组!!!!
for (int num : temp){
System.out.println(num + ",");
}
System.out.println();
}
}
}
标签:int,System,二维,6.4,数组,println,data,out
From: https://www.cnblogs.com/pansidong/p/17454152.html