title: How to make a variable increment on every running of a method?
body: <p>I am trying to get the int count to increment each time I run the program. ie: So if I ran the program 9 times, and doMethod was called 9 times, the value of count would be 9. But since I have to initialize count to = 0 count keeps resetting itself to 0 on every iteration of the method. Is there a way around this?</p>
  
  <pre><code>public class Test {
  
      public static void main (String[] args) {
  
          Test test1 = new Test();
  
          test1.doMethod();
  
      }
  
      public void doMethod ()  {
  
          int count = 0;
  
          count++;
          System.out.println(count);
      }
  }
  </code></pre>