Java操作二维数组实例

发表于:2007-06-22来源:作者:点击数: 标签:

   
  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);
  }
  }

原文转自:http://www.ltesting.net