title: How to check if array[] has a null value in java?
body: <p>I am reading a csv file. One of the requirements is to check if a certain column has a value or not. In this case I want to check the value in <code>array[18]</code>. However, I am getting </p>
  
  <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 18
  </code></pre>
  
  <p>Is there any other way to check the array index if it has a value or empty?</p>
  
  <p>My code:</p>
  
  <pre><code>while ((sCurrentLine = br.readLine())!= null) { 
  
      String[] record = sCurrentLine.split(",");   
  
      if(record.length &gt; 0){ // checking if the current line is not empty on the file
         if(record[18] != null){ // as per console, I am getting the error in this line
            String readDateRecord = record[18];
            // other processing here
         }
      }
  }
  </code></pre>