Java 操作二维数组实例
2008-01-05 09:52:44 来源:WEB开发网核心提示:import java.util.*; public class MultiDimArray { static Random rand = new Random(); static int PRand(int mod) { return Math.abs(rand.nextInt()) % mod + 1; } pub
import java.util.*;
public class MultiDimArray {
static Random rand = new Random();
static int PRand(int mod) {
return Math.abs(rand.nextInt()) % mod + 1;
}
public static void main(String[] args) {
int[][] a1 = {
{ 1, 2, 3, },
{ 4, 5, 6, },
};
for(int i = 0; i < a1.length; i++)
for(int j = 0; j < a1[i].length; j++)
prt("a1[" + i + "][" + j +
"] = " + a1[i][j]);
}
static void prt(String s) {
System.out.println(s);
}
}
更多精彩
赞助商链接