Adding 2D array

 

public class RotaionArray {

    public static void main(String[] args) {

        int A[][]={{1,2,3},{8,5,2},{5,6,7}};

        int B[][]={{5,6,7},{8,5,2},{1,2,3}};

        int C[][]=new int[3][3];//A & B er row colum jog kore same C er row colum e rakhchi

        for (int i=0;i<A.length;i++){

          for( int j=0;j<A.length;j++){//here ‘i’ represent colum and ‘j’ row element

             C[i][j]=A[i][j]+B[i][j] ;//adding A with correspondent row, colum of B

              System.out.print(C[i][j]+”,”);

            }

            System.out.println();

        }

        

    }

    

}

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top