title: How to solve "Cannot Make Static Reference to Non-Static Method" in a Java mastermind game?
body: <p>This question is based on my former question. <a href="https://stackoverflow.com/questions/29881516/how-to-add-a-cheat-function-to-a-java-mastermind-game/29882449?noredirect=1#comment47890899_29882449">How to add a &quot;cheat&quot; function to a Java mastermind game</a>
  I added the cheat function to my program, but it cannot compile because of "Cannot Make Static Reference to Non-Static Method"(the old codes works, you can check it through the link I post). Here are my new codes:</p>
  
  <pre><code>import java.util.*;
  
  public class mm {
    static int[] random;
    public static void main(String[] args) {
      System.out.println("I'm thinking of a 4 digit code.");
  
      //update
      mm m1 = new mm();
      random = m1.numberGenerator();
  
      int exact=0, close=0;
      while(exact!=4){
        int[] guess= m1.userinput(); //update
        exact=0;
        close=0;
        for(int i=0;i&lt;guess.length;i++){
          if(guess[i]==random[i]){
          exact++;
          }
          else if (random[i]==guess[0] || random[i]==guess[1] || random[i]==guess[2] || random[i]==guess[3]) {
                      close++;
          }
        }
        if(exact==4){
          System.out.println("YOU GOT IT!");
        }
        else{
          System.out.println("Exact: "+exact+" Close: "+close);
        }
      }   
    }
  
    public int[] userinput() {
      System.out.print("Your guess: ");
      Scanner user = new Scanner(System.in);
      String input = user.nextLine();
      //cheater
      if (input.equals("*")) {
        System.out.format("Cheater!Secret code is:");
        for(int i=0;i&lt;random.length;i++){
          System.out.print(random[i]);
        }
      }
      int[] guess = new int[4];
      for (int i = 0; i &lt; 4; i++) {
        guess[i] = Integer.parseInt(String.valueOf(input.charAt(i)));
      }
      return guess;
    }
  
    public int[] numberGenerator() {
      Random rnd = new Random();
      int[] randArray = {10,10,10,10};
      for(int i=0;i&lt;randArray.length;i++){
        int temp = rnd.nextInt(9);
        while(temp == randArray[0] || temp == randArray[1] || temp == randArray[2] || temp == randArray[3]){
          temp=rnd.nextInt(9);
        }
        randArray[i]=temp;
      }
      return randArray;
    }
  }
  </code></pre>
  
  <p>How to solve this?</p>