title: Generating random number of loops
body: <p>I have this problem that I have observed when generating numbers as a condition in a for loop.
  I use this in my android program.</p>
  
  <p>When I do this:</p>
  
  <pre><code>String temp = "";
  for (int i = 0; i &lt; new Random().nextInt(1000); i++) {
      temp += i + " ";
  }
  </code></pre>
  
  <p>I always get no more than 100</p>
  
  <p>But when I do this:</p>
  
  <pre><code>for (int i = 0; i &lt; 10; i++) {
      temp += new Random().nextInt(1000) + " ";
  }
  </code></pre>
  
  <p>I got real random numbers ranging from 0 to 999.</p>
  
  <p>What is actually happening?</p>
  
  <p>I know I could do this:</p>
  
  <pre><code>int x = new Random().nextInt(1000);
  for (int i = 0; i &lt; x; i++) {
      temp += i + " ";
  }
  </code></pre>
  
  <p>And this does return random numbers from 0-999. But I just want to understand why the first code only returns numbers not more than 100.</p>