title: Total amount of elements in two dimensional array
body: <p>Recently we learned two dimensional arrays and solved task of calculating average of all elements in it. My code was like:</p>
  
  <pre><code>int a[][] = {
    {1, 2, 3, 4, 5},
    {6, 4, 2, 7},
    {3, 6},
    {2, 6, 8},
  };
  
  int sum=0, amount=0;
  for (int[] row : a)
    for (int val : row) {
      sum += val; amount += 1;
    }
  
  return sum / (double) amount;
  </code></pre>
  
  <p>The thing is that I don't like the way I calculated the amount of elements in array.
  I tried to use <strong>size()</strong>, it not worked, tried to use Array and Arrays classes but both can retrieve neither amount of rows nor amount of elements in some row, just as a <strong>.length</strong> property.</p>
  
  <p><strong>Question:</strong> is there <strong>any way</strong> of retrieving the amount of elements from two or more dimensional matrices without using loops?</p>