title: How do I get the getX() method of Java Point to work?
body: <p>I'm trying to program a swarm of birds in Java for a project in school. As I'm only doing this in 2d, I thought it would be best to use an array of <code>Points</code> as it would provide me with x and y coordinates.
  However, when trying to use the <code>getX()</code> or <code>getY()</code> methods on a <code>Point</code>, I get a "Cannot resolve method" error.</p>
  
  <p>This is my method to assign x and y positions to the <code>Point</code> array of my "birds":</p>
  
  <pre><code>    public Point[] pointArray() {             
  
      points[0] = new Point(100, 100);                            
      Random randGen = new Random();
  
      for (int i = 1; i &lt; points.length; i++){
          randX = (randGen.nextInt(5)-2);                         
          randY = (randGen.nextInt(5)-2);
          points[i] = new Point(100+randX, 100+randY);
      }
      return points;
  }
  </code></pre>
  
  <p>And in this method I draw my "birds":</p>
  
  <pre><code>    public void paintComponent(Graphics g) {
  
      super.paintComponent(g);
      Point[] coordinates = pointArray();
      g.setColor(Color.BLACK);
      g.fillRect(0, 0, this.getWidth(), this.getHeight());
      g.setColor(Color.WHITE);
  
      for(int i = 0; i&lt;coordinates.length; i++ ) {
          int x = coordinates[i].getX();
          int y = coordinates[i].getY();
          g.fillOval(x, y, 5, 5);
      }
      }
  </code></pre>
  
  <p>Like I said, I get a "Cannot resolve method" error on the <code>getX()</code> and <code>getY()</code> methods and I can't see why. I also tried to first extract a single<code>Point</code> of the array and then use the methods on it but I get the same error. All i could find was <a href="https://stackoverflow.com/questions/10221327/java-point-difference-between-getx-and-point-x">this question</a> and I called the method like they did.</p>
  
  <p>I'm pretty new to Java and programming in general, so any help is greatly appreciated.
  This is my first post here and I'm glad to be part of the community, you guys helped me out more than once already :)</p>