title: Java program to generate a unique and random six alpha numeric code
body: <p>I need to generate a reservation code of 6 alpha numeric characters, that is random and unique in java.</p>
  
  <p>Tried using <code>UUID.randomuuid().toString()</code>, However the id is too long and the requirement demands that it should only be 6 characters.</p>
  
  <p>What approaches are possible to achieve this?</p>
  
  <p>Just to clarify, (Since this question is getting marked as duplicate).
  The other solutions I've found are simply generating random characters, which is not enough in this case. I need to reasonably ensure that a random code is not generated again.</p>