title: Getting same number when using Math.random() and ThreadLocalRandom.current().nextDouble() and Random class nextDouble() method?
body: <p>A BankApplication program in Java, problem in <code>setDebitCard()</code> function.</p>
  
  <p>Here I am not able to generate a unique random number after every <em>java run</em> for <code>debitCardNumber</code> variable while it is working fine with <code>debitCardPin</code>.</p>
  
  <p>I tried working with Random class method 
  <code>nextDouble(),Math.random()</code>, <code>ThreadLocalRandom.current().nextDouble()</code> too..</p>
  
  <p>Problems:</p>
  
  <ol>
  <li><p>The <code>debitCardNumber</code> output is the same after trying everything mentioned above. (No syntax error whatsoever)</p></li>
  <li><p>Also, I am getting the same 10 digits <code>debitCardNumber</code> instead of 12 digits.</p></li>
  <li><p><code>debitCardPin</code> is working fine, But Sometimes it gives me a unique 3 digit random number.</p></li>
  </ol>
  
  <p><strong><em>CODE</em></strong></p>
  
  <pre><code>package bankAccountApp;
  
  import java.util.Random;
  
  import java.util.concurrent.ThreadLocalRandom;
  
  public class Current extends Account {
  
      private int debitCardNumber;
  
      private int debitCardPin;
  
      Random rand = new Random();
  
  //setDebitCard() code
  
  private void setDebitCard(){
  
      debitCardNumber = (int)(ThreadLocalRandom.current().nextDouble()*Math.pow(10,12));
  
  
  /* Also tried using
  
     debitCardNumber = (int)(rand.nextDouble()*Math.pow(10,12));
  
     debitCardNumber = (int)(Math.random()*Math.pow(10,12));
  
  */
  
      debitCardPin = (int)(Math.random()*Math.pow(10,4));
      }
  </code></pre>
  
  <p>Expected Result:</p>
  
  <ol>
  <li><p><code>debitCardNumber</code> should return a unique random 12 digit integer after every <strong><em>JAVA RUN</em></strong></p></li>
  <li><p><code>debitCardPin</code> should return only 4 digit integer.</p></li>
  </ol>
  
  <p>Actual Result:</p>
  
  <ol>
  <li><p><code>debitCardNumber</code> returns same 10 digit integer after every <strong><em>JAVA RUN</em></strong></p></li>
  <li><p><code>debitCardPin</code> sometimes returns a 3 digit unique random integer.</p></li>
  </ol>