title: Assured 6 digit random number
body: <p>I have to Generate a 6 digit Random Number. The below is the Code that I have done so far. It works fine but some time its giving <strong>7 digits</strong> in place of <strong>6 digits</strong>.  <br><br>
  The main question is why?  <br><br>
  How do I generate an assured 6 digit random number?</p>
  
  <pre><code>val ran = new Random()
  val code= (100000 + ran.nextInt(999999)).toString
  </code></pre>