title: Don't understand how Math.random() works in java
body: <p>Why does the following code prints just 25?</p>
  
  <pre><code>while(true) {
      int pos = (int) (Math.random() * (26 ));
      if (pos &gt; 24)
          System.out.println(pos);
  }
  </code></pre>
  
  <p>If <code>Math.random()</code> returns a number from <code>0</code> to <code>1</code> then shouldn't the code above print also <code>26 (1*26 = 26)</code>?</p>