title: How can I increment a variable on button click?
body: <p>I'm trying to make a small game like thing for school. It's designed to help you learn your times tables. What I want is for the multiplier of the table to be random each time (5x8 then 5x3 then 5x9 etc).</p>
  
  <p>I've got the generating of the numbers in control with an array as can be seen below</p>
  
  <pre><code>public static Integer[] generateNumbers()
  {
      Integer[] arr = new Integer[12];
  
      for(int j = 0; j &lt; arr.length; j++)
      {
          arr[j] = j+1;
      }
      Collections.shuffle(Arrays.asList(arr));
      System.out.println(Arrays.asList(arr));
      return arr;
  }
  </code></pre>
  
  <p>How can I make it so that every time the user clicks a button, the next number in the array is selected, baring in mind that the button is declared in another class, and the ActionListener is also declared elsewhere?</p>
  
  <p>Oh and the array is available class-wide as the function is declared like this:</p>
  
  <pre><code>public static Integer[] arr = generateNumbers();
  </code></pre>