title: how to auto increase data field in java oop class
body: <p>I have this class</p>
  
  <pre><code>public class NInfo {
  private  int val;
  private static int indx=1;
  
  public NInfo(int val) {
      this.val = val;
      this.indx++;
      }
  }
  </code></pre>
  
  <p>I would like to auto increase the indx in every new object that I create starting 1
  this code doesnt work , what shall I fix ?</p>