title: Changing a variable outside the scope of a method in Java
body: <p>So I'm trying to change the value of a minimum and maximum guess (with the actual guess being made by a random number generator) in order to stop the program from guessing the same number twice.</p>
  
  <p>I have a method that makes a guess but also tries to set a lowest and highest guess which then changes when the method is used again</p>
  
  <pre><code>public static int takestab (int low, int high) {  
      int estimate;
      estimate = (low + (int)(Math.random() * ((high - low) + low)));
  
      if (estimate &lt; number) {
          lowestguess = estimate;
      }
      else if (estimate &gt; number) {
          highestguess = estimate;
      }
      return estimate;
  }
  </code></pre>
  
  <p>Also, these are the vars I have outside of the method scope:</p>
  
  <pre><code>    int lowestguess = 1;
      int highestguess = 100;
  </code></pre>
  
  <p>So by running that method, the guess could be 50 and the actual number could be 60. if that's the case, then "lowestguess" becomes 50 so that the function can't guess any lower than 50.</p>
  
  <p>When I try it this way, the cmd prompt says that it cant find the matching symbol.</p>
  
  <p>Any ideas?</p>