title: How to obtain a part of a 2d array?
body: <p>Suppose if I have a 4x4 array matrix like </p>
  
  <pre><code>aaaa
  abba
  abba
  aaaa
  </code></pre>
  
  <p>Can I obtain a 3x3 matrix from the above matrix and store it in another 2d array. The 3x3 matrix should contain the elements</p>
  
  <pre><code>aaa
  abb
  abb 
  </code></pre>
  
  <p>likewise </p>
  
  <pre><code>aaa
  bba
  bba
  </code></pre>
  
  <p>and two more matrices.</p>
  
  <p>Can this be done using Arrays.copyOfRange ??</p>
  
  <p>EDIT: I also want the other 2 3x3 matrices ie.</p>
  
  <pre><code>abb
  abb
  aaa
  </code></pre>
  
  <p>and </p>
  
  <pre><code>bba
  bba
  aaa
  </code></pre>
  
  <p>Like if I pass the elements in the 2x2 matrix which in the 4x4 ie. b's , it should give me a 3x3 matrix surrounding the element. </p>
  
  <p>I can make this happen by using a for loop which takes the i and j values from subtracting 1 from the index of the element ( here 'b')  which I'm passing , which results in a 3x3 matrix surrounding the value b ( given above ) . But just want to know if there is an easier way. </p>