title: 2 dimensional string array declaration, Exception in thread "main" java.lang.NullPointerException java
body: <p>I'm new to java programming and I can't find a solution to my problem. I think it's a pretty easy problem but I can't figure a what I'm doing wrong so I hope one of you could help me. The problem is when I try to store some data in an array it returns the following error: </p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
  </code></pre>
  
  <h2>Code</h2>
  
  <pre><code>public class FetchData{
      private String rows[][];
      private int rowCount;
  
      public FetchData(){
          rowCount = 0;
      }
  
      public boolean ConnectAndFetch(String start, String end){
  
          //not relevant to the problem
          for(...){
              List&lt;WebElementdivList = driver.findElements(By.tagName("div"));
  
              int divCount = 0;
              int colCount = 0;
              for (WebElement elem : divList) {
                  if(divCount 24){ 
                      if(colCount &lt; 17){
                          System.out.println(elem.getText());
                          //System.out.println(colCount);
                          //System.out.println(rowCount);
                          rows[rowCount][colCount] = elem.getText();
                          colCount++;
                      } else { 
                          rowCount += 1;
                          colCount = 0;
                      }
                  }
                  divCount++;
              }
          }
          return true;
      }
  </code></pre>
  
  <p>I think it has something to do with the declaration <code>private String rows[][];</code> but I don't know how to fix it. I'd appreciate your help!</p>