java二维数组加法

2019年2月16日20:59:38 发表评论 1,111 views
/**
 * Created by xabcd on 2019/2/16.
 */
public class java_secarr
{
    public static void main(String args[]) {
        int A[][] = {{55, 23, 12, 56, 25}, {12, 88, 42, 999}};
        int B[][] = new int[2][5];
        B = add(A);

        //打印数组
        for (int i = 0; i < B.length; i++) {
            for (int j = 0; j < B[i].length;
            j++){
                System.out.print(B[i][j] + "  ");
            }
            System.out.print("\n");
        }
    }

        public static int[][] add(int arr[][]) {//此处要用两个int【】【】
            for(int i = 0;i<arr.length;i++){
                for(int j = 0;j<arr[i].length;j++){
                    arr[i][j] = arr[i][j] + 10;
                }
            }
            return arr;

        }



}

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: