title: I can not increase the studentid value in For
body: <p>I am doing some coding in Java, but it doesn't work:</p>
  
  <p>import java.util.Scanner;</p>
  
  <p>import java.util.Arrays;</p>
  
  <p>public class Main
  {</p>
  
  <pre><code>    public static void main(String[] args) 
      {
          Scanner input = new Scanner(System.in);
  
          String [] studentId = new String [3];
  
          Student name;
  
          for (int i = 0; i &lt; 3; i++) 
          {
          System.out.print("Enter Name =&gt; ");
          name = new Student(input.next());
          studentId[i] = name.toString();
          }
          for (int i = 0; i &lt; 3; i++) 
          {
          System.out.println(studentId[i]);
          }    
  }
  }
  </code></pre>
  
  <pre><code>public class Student
  {
      private static int studentId;
      private String name;
  
      public Student(String name) 
      {
      this.name=name;    
      setStudentId(studentId++);
      }
  
      public int getStudentId() 
      {
      return studentId;
      }
  
      public void setStudentId(int studentId) 
      {
      this.studentId = studentId;
      }
  
      @Override
      public String toString()
      {
          return (this.studentId +" "+ "student is "+ " " + "(" + this.studentId + ")"+ this.name);
      }
  }
  </code></pre>
  
  <p>I need to auto-increment the Id when a new entry is created.
  I try everything but still cant increased it.</p>