title: Java - How to make a variable that can be used anywhere?
body: <p>I want to make a variable that I can use inside my method to change that variable outside my method. As a visual: (I imported the scanner class by the way)</p>
  
  <pre><code>public static void main(String[] args) {
  
      int quitVar = 1;
      Scanner scan = new Scanner(System.in);
  
      class IWantToQuit {
          public void quit() {
              quitVar++; //This is the problem area.
          }
      }
      IWantToQuit quiter = new IWantToQuit();
      while (quitVar == 1) {
          System.out.println("HELLO");
      System.out.println("Type QUIT to quit.");
      choice = scan.next();
      if (choice.equals("QUIT")) {
          quiter.quit();
      }
  </code></pre>
  
  <p>For some reason, it says that the local variable quitVar is accessed by the inner class but it needs to be declared and I have declared it. Any help is appreciated.</p>