title: Getter and Setter in Array
body: <p>I need help for unexpected output from my code below.
  I was create a class I called "Student" and mainclass I called "MainStudent", I don't have wrong code when I try make Student object to Array and input data using setter, but when I run my code then the output is says like this one:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NullPointerException</p>
  </blockquote>
  
  <p>I'm using NetBeans for write my java code.</p>
  
  <pre><code>import javax.swing.JOptionPane;
  public class MainStudent {
  
      public static void main(String[] args) {
          String a,b;
          int c;
          Student[] std = new Student[3];
          for(int i=0; i&lt;std.length; i++){
              a = JOptionPane.showInputDialog("Enter Student Name");
              b = JOptionPane.showInputDialog("Enter Student Address");
              c = Integer.parseInt(JOptionPane.showInputDialog("Enter Student Phone Number"));
              std[i].setName(a);
              std[i].setAddress(b);
              std[i].setPhone_number(c);
          }
  
          for(int i=0; i&lt;std.length; i++){
              System.out.println(std[i].getName());
          }
      }
  
  }
  </code></pre>