I can not generate sequential ID in Java, help

Hello, I am starting to program in java and I am creating a user object, I am trying to generate a sequential identifier for each user registered in the system.
I am totally lost in how to do this method.
to do this: (sorry if the code is confusing)
** public class User {

int id = 1;
public void generated () {}
ID ++;

public class Mein {
public static void main (String[] args) {
User u1 = new User ();

u1.gerarid ();

hence each user leaves with the same number of the generated id.