Declare ID em Java

static	int count=0;
		int id=0;
    
    public Car() {
        this.id=count++;
    }
Prickly Pygmy