类 / 构造函数

class Man {
    private static int nextId;      
    public int id;

    static {
        nextId = getLastDbId();
    }

    {
        nextId++;
        id = nextId;
    }   

    static int getLastDbId() {
        //some implementation
        return 0;
    }
}

var man = new Man();
//man.id is 1

System.out.println("man.id is " + man.id);