title: JAVA Can someone explain this code for me? Auto-Gen
body: <p>I found these codes online at:</p>
  
  <p><a href="http://www.java2s.com/Code/Java/Security/GeneratearandomStringsuitableforuseasatemporarypassword.htm" rel="nofollow">http://www.java2s.com/Code/Java/Security/GeneratearandomStringsuitableforuseasatemporarypassword.htm</a></p>
  
  <p>But I am not really sure about the codes' logic.</p>
  
  <pre><code>public static String generateRandomPassword()
  {
  
        String letters = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789";
  
        String pw = "";
        for (int i=0; i&lt;PASSWORD_LENGTH; i++)
        {
            int index = (int)(RANDOM.nextDouble()*letters.length());
            pw += letters.substring(index, index+1); 
        }
        return pw;
  }
  </code></pre>
  
  <p>Can someone explain this two lines of codes for me so I can understand better?</p>
  
  <pre><code>int index = (int)(RANDOM.nextDouble()*letters.length());
  pw += letters.substring(index, index+1); 
  </code></pre>
  
  <p>Thank You. :D</p>