title: Array of random numbers as Object in java
body: <p>I am new at java and want to ask you one question. So first what I have to do: My goal is to create different points in one area. I decided to create a class <code>Koord</code> for saving the coordinates of the points. I have used an array of 2 elements for this - for the x and y value. After that I added a random generator for x and y (they have to be random). </p>
  
  <p>Here is my class:</p>
  
  <pre><code>import java.util.Random;
  
  public class Koord {
  
  private int number;
  
  private static int numberOfNodes = 0;
  
  public static int[] koord;
  
  public Koord(int x, int y){
      koord = new int[2];
      koord[0] = x;
      koord[1] = y;
      number = ++numberOfNodes;
      }
  
  public int getNumber() {
      return number;
  }
  
  public static int getNumberOfNodes() {
      return numberOfNodes;
  }
  
  private static int randomFill(){
      Random rand = new Random();
      int randomNum = rand.nextInt(99);
      return randomNum;
  }
  
  public int getX(){
      return koord[0] = randomFill();
         }
  
  public int getY(){
      return koord[1] = randomFill();
      }
  
  }
  </code></pre>
  
  <p>So, until now everything is OK. But now at my main class, I want to create some points and add them to a list. This is also not a problem. The problem starts when I want to print the coordinates of the points. As I am calling the methods <code>getX()</code> when I am printing the coordinates of the points in the list, I am getting different coordinates every time. </p>
  
  <pre><code>import java.util.LinkedList;
  import java.util.ListIterator;
  
  
  public class Display {
       public static void main(String args[]) {
           LinkedList&lt;Koord&gt; ownArea = new LinkedList&lt;Koord&gt;();
  
        Koord point1 = new Koord(0, 0);
        Koord point2 = new Koord(0, 0);
        Koord point3 = new Koord(0, 0);
        Koord point4 = new Koord(0, 0);
        Koord point5 = new Koord(0, 0);
        Koord point6 = new Koord(0, 0);
        Koord point7 = new Koord(0, 0);
  
  
        ownArea.add(point1);
        ownArea.add(point2);
        ownArea.add(point3);
        ownArea.add(point4);
        ownArea.add(point5);
        ownArea.add(point6);
        ownArea.add(point7);
  
  
  
        System.out.println("ListIterator Approach: ");
          ListIterator&lt;Koord&gt; listIterator = ownArea.listIterator();
          while (listIterator.hasNext()) {
              System.out.println(listIterator.next().getX());
          }
  
        System.out.println("ListIterator Approach: ");
          ListIterator&lt;Koord&gt; listIterator2 = ownArea.listIterator();
          while (listIterator2.hasNext()) {
              System.out.println(listIterator2.next().getX());
          }
  
  
  
  
   }
  }
  </code></pre>
  
  <p>So I know where the problem is, I know that this is wrong, but I don't know how to assign static coordinates to every point and how to print them. And I need this, because I want to operate with the coordinates (comparing them, printing them and so on). I know I have to learn a lot, but for now it will be very helpful, if you can give me some advice.</p>