title: Class identifier without risk of integer overflow
body: <p>Is there any smart solution to avoid the risk of integer overflow when you try to give an unique identifier to each object of a class ?</p>
  <p>For example, in Java :</p>
  <p>if I have an attribute like this</p>
  <pre class="lang-java prettyprint-override"><code>private static int nextID = 0;
  </code></pre>
  <p>and my constructor looks like</p>
  <pre class="lang-java prettyprint-override"><code>    public MyClass() {
          this.id = nextID++;
      }
  </code></pre>
  <p>In all likelyhood, if I create too many objects, I will get an integer overflow and the ID will no longer be a unique value.</p>
  <p>How could I avoid this behavior ?</p>