title: Generating Random Doubles in Java
body: <p>I'm a Java noob trying to generate a random double between -10 and 10 inclusive. I know with ints I would do the following: </p>
  
  <pre><code>Random r = new Random(); 
  int i = -10 + r.nextInt(21);
  </code></pre>
  
  <p>However, with doubles, this doesn't work: </p>
  
  <pre><code>Random r = new Random(); 
  double i = -10 + r.nextDouble(21); 
  </code></pre>
  
  <p>Can someone please explain what to do in the case of doubles? </p>