title: Generate auto increment number by using Java
body: <p>I am trying to generate unique auto increment id which will started from <code>0</code>.
  I found something for doing this using below code:</p>
  
  <pre><code>private static final AtomicInteger count = new AtomicInteger(0);   
  uniqueID = count.incrementAndGet(); 
  </code></pre>
  
  <p>I can create auto increment ID by manually :</p>
  
  <p>For example : </p>
  
  <pre><code>int i = 0; // Obviously I will declare this variable as global
  ++i;
  </code></pre>
  
  <p>In this way I can manage to do this. But I don't want to do this manually. I am finding some java method which will take of all this stuff. </p>
  
  <p>And I found below code :</p>
  
  <pre><code>private static final AtomicInteger count = new AtomicInteger(0);   
  uniqueID = count.incrementAndGet(); 
  </code></pre>
  
  <p>Now my question is, Is this the right way to generate unique ID? Or, is there any other better solution?</p>