title: Check if a Row exists in a 2D array in Java
body: <p>I am having trouble fixing my code so that I stop getting </p>
  
  <pre><code>java.lang.ArrayIndexOutOfBoundsException: 6
  </code></pre>
  
  <p>Here is my current code:</p>
  
  <pre><code>    public static boolean isRow(int row, double[][] array)
      {
      boolean flag = false;
  
      if ( array != null &amp;&amp; array.length &gt;= 0 )
      {
          if ( array[row] != null )
          {
              flag = true;
          }
      }
      return flag;
      }
  </code></pre>
  
  <p>I know that I will probably have to have a for loop somewhere so that it can check to see that </p>
  
  <p><code>!(row &gt; array.length);</code></p>
  
  <p>But I am just not sure how to write that in. I am using a JUNIT test that is trying to pass "6" in as the row variable.</p>
  
  <p>Any help is greatly appreciated!</p>