用2个for循环能完成么?小弟刚学没多久。。

解决方案 »

  1.   

    二维数组两个for可以的,你想一维可以用一个for遍历,二维就相当于有行有列,你要遍历行,还要遍历列
      

  2.   

    可以  只是你要是想从键盘获取 可能你要去看看 API函数啦  嘿嘿
      

  3.   

    晕。
    没人写个么?我自己试了下,总是OutOfBoundsException。 如何解决?
      

  4.   

    呵呵, 可以搞定,但用到反射哦     public static void printArray(Object  source){
              if(source==null)return;
              if(source.getClass().isArray()){
                 Object[]objs=(Object[])source;
                 for(Object obj:objs){
                     printArray(obj);
                  }
              }else{
                System.out.print(source);
              }
         }不管你数组维数有多长,都能搞定,
      

  5.   


    int[][] a = .....;
    for (int i = 0; i < a.length(); i++){
        for (int j = 0; j < a[i].length; j++){
            a[i][j] = ....;
            // 自己赋值
        }
    }