title: Java create a unique ID for each instantiated object using instance methods instead of class/static methods
body: <p>Quite new to this so I hope I have the terminology in the title right.</p>
  
  <p>I am trying to figure out how to create an <strong>instance method</strong> that will do the following:</p>
  
  <p>--An ID number is returned.</p>
  
  <p>--As each object is created from the class constructor(instantiated?), a unique integer ID number is assigned to it. The first ID number is 1, and as new objects are instantiated, successive numbers will be assigned.</p>
  
  <p>I am able to find examples of class/static methods that do the above however I am unable to figure out how to do this with an instance method. My attempt is below:</p>
  
  <pre><code>class Coordinates
  {
      private int iD = 0;
      private float xCoordinate;
      private float yCoordinate;
  
      public Coordinates()
      {
          //Asks for input and assigns it to the two variables below
          Scanner keyboard = new Scanner(System.in);
          System.out.println("Please enter the X Coordinate followed by the return key");
          xCoordinate = keyboard.nextDouble();
          System.out.println("Please enter the Y Coordinate followed by the return key");
          yCoordinate = keyboard.nextDouble();
  
          iD++;
      }
  
      public getiD()
      {
          return iD;
      }
  
  }
  </code></pre>
  
  <p>My main method is as follows:</p>
  
  <pre><code>public class Machine
  {
      public static void main(String[] args)
      {
          Coordinates c1 = new Coordiantes();
          Coordinates c2 = new Coordiantes();
          Coordinates c3 = new Coordiantes();
  
          System.out.println("ID: " + c1.getID());
          System.out.println("ID: " + c2.getID());
          System.out.println("ID: " + c3.getID());
  
  
      }
  }
  </code></pre>
  
  <p>Please note I have not included my entire code for the sake of simplicity and easiness to follow. I hope I have added enough.</p>
  
  <p>I also don't want to use java.util.UUID.</p>