title: How do I return 0 if random number will be negative?
body: <p>The num1, num2, are bounds of the random number, but I want the result to be 0 if num1 is greater than num2.</p>
  
  <pre><code>int num1 = 5
  int num2 = 1
  int num3 = 10
  Random rand = new Random();
      double num = 0;
      for (int i = 0; i &lt; num3; i++) {
          int randNum = rand.nextInt((num2 - num1) + 1) + num1;
          num = num + randNum;
      // Adds the random number generated to num until it reaches the
      // max amount of numbers generated.
      }
  
      num = num / num3;
      if (num3 &lt; 1 || num2 &lt; num1){ 
          return 0;
      } else {
          return num;
      }
  </code></pre>
  
  <p>I thought the last if statement would work, but it keeps giving me an error that says the random number cannot be negative.</p>
  
  <p>If the solution could be a little simple as I am only just starting on Java</p>
  
  <p>Any help would be much appreciated, thanks</p>