title: How to increment variable in a class every time i make a new object of said class
body: <p>I have a variable in another class for an id in java. I want it to start from 0 and increment every time afterwards that the new id will be 1 and so on.
  I got the idea of declaring a new variable called <code>id</code> in the main class, every time I create a new object I will call the method <code>setId</code> with the new id and then increment the variable again. But is there another way to do it? (keep in mind the constructor for the class dose not have ID and I can't change the constructors)</p>