title: How do I generate a random number between -1000 and 1000?
body: <p>Good day,</p>
  
  <p>I am coding the "Guess the number" game in java and I'm trying to get the program to generate a number between -1000 and 1000 but for some reason, it only generates numbers above 1 right now.</p>
  
  <p>What exactly have I done wrong here? 
  Could anybody help me out?</p>
  
  <pre><code>    Random rand = new Random();
      int numberToGuess = rand.nextInt((1000 - (-1000) + 1) + (-1000));
      int numberOfTries = 0;
      Scanner input = new Scanner(System.in);
      int guess;
      boolean win = false;
  
      System.out.println("Lets begin.");
  
      while (win == false &amp;&amp; numberOfTries &lt; 11) {
  
          System.out.println("Insert a number:");
          guess = input.nextInt();
          numberOfTries++;
  
  
          if (guess == numberToGuess) {
              win = true;
          }
  
          else if (guess &lt; numberToGuess) {
          System.out.println("Your guess is too low.");
          }
  
          else if (guess &gt; numberToGuess) {
          System.out.println("Your guess it too high.");
          }
  
  
      }
  
      if (win == true)
      System.out.println("You won with " + numberOfTries + " attempts. The hidden number was " + numberToGuess + ".");
  
      else if (numberOfTries == 11) {
          System.out.println("You lost. The number was " + numberToGuess + ".");
      }
  
  
  
  }
  
  
  }
  </code></pre>