title: Java: How to use a counter in register using ArrayList
body: <p>I wanted the ID was 1,2,3,4 each new name, ie</p>
  
  <p>ID - Name - Age</p>
  
  <p>1 - Paul - 60</p>
  
  <p>2 - Regis - 25</p>
  
  <p>3 - Ana - 20</p>
  
  <p>automatic ID</p>
  
  <pre><code>static void register(ArrayList mylist) {
          int i = 1;
          Scanner in = new Scanner(System.in);
          Peoples p = new Peoples();
  //        System.out.print("ID: ");
  //        p.ID = in.nextInt();
          p.ID = i;
          i++;
          in.nextLine();
          System.out.print("Name: ");
          p.name = in.nextLine();
          System.out.print("Age: ");
          p.age = in.nextInt();
          mylist.add(p);
      }
  
  
  public class Peoples {
      public int ID;
      public String name;
      public int age;
  }
  </code></pre>