title: Null Pointer Exception while using objects as array
body: <p>This is my EmpData Class:</p>
  
  <pre><code>package com.bank;
  
  public class EmpData {
  int id;
  String name;
  String date;
  String pos;
  String status;
  
  
  public void setEmp(int id, String name, String date) {
      this.id = id;
      this.name = name;
      this.date = date;
  }
  
  public void setStat(String pos, String stat){
      this.pos = pos;
      this.status = stat;
  }
  
  public void disp(){
      System.out.println(id+" : "+name+" : "+date+" : "+pos+" : "+status);
  }
  
  }
  </code></pre>
  
  <p>This is my Main Class:</p>
  
  <pre><code>package com.bank;
  
  public class Bank {
      public static void main(String[] args) {
          EmpData[] obj = new EmpData[4];
          obj[1].setEmp(1, "Test123", "09-04-1990");
          obj[1].setStat("clerk", "on-hold");
          obj[1].disp();
      }
  }
  </code></pre>
  
  <p>i got no syntax error in eclipse, but when i run the program i get the following null pointer error </p>
  
  <p>Exception in thread "main" java.lang.NullPointerException
      at com.bank.Bank.main(Bank.java:6)</p>