title: Generate random doubles in between a range of values - Java
body: <p>I have written this piece of code which generates random doubles in between -1 and 1. The only problem is that it only produces one random double and then just prints out that for the other doubles that I want to produce. E.g. if the first double is 0.51 it just prints 0.51 over and over again instead of generating new random doubles.</p>
  
  <p>What is wrong with the following code?</p>
  
  <pre><code>public static void main(String[] args) {
      double start = -1;
      double end = 1;
      double random = new Random().nextDouble();
  
      for(int i=1; i&lt;10; i++){
          double result = start + (random * (end - start));
  
          System.out.println(result);
      }
  }
  </code></pre>
  
  <p>Thanks in advance!</p>