// processing matrix with for each loop

import java.io.*;
public class test2
 {private int[][] ma = new int[3][4];
     
     public test2()
       {for (int r = 0; r < ma.length; r++)
            for (int c = 0; c < ma[r].length; c++)
               ma[r][c] = (int)(Math.random() * 10);
            }
            
      public int sum()
       {int sum = 0;
           for (int ar[] : ma)
          for (int nu : ar)
            sum += nu;
            return sum;
        }
        
     public void print()
      {for (int[] ar : ma)
         {  for (int num : ar)
            System.out.print(num + " ");
            System.out.println();
        }   
   }
}