title: How to set values to object attributes inside an array in java
body: <p>I keep getting this error: </p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at Circle.main(Circle.java:35)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
  </code></pre>
  
  <p>I'm trying to set the attributes for the first circle object, but I guess I can't do this in java this way?</p>
  
  <pre><code>public class Circle {
      private double x,
                     y,
                     radius;
  
      public static void main(String args[]) {
          // Testing Circles
          System.out.println("\nTESTING CIRCLES:");
          Circle[] circles = new Circle[2];
          Circle circle1 = circles[0]; // Circle 1
  
          // Setting X
          circle1.setX(20);  // &lt;- Why does this not work and how is this properly done.
      }
  
      public void setX(double xVal) {
          x = xVal;
      }
  }
  </code></pre>