title: Non static method cannot be referenced from a static context?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/290884/what-is-the-reason-behind-non-static-method-cannot-be-referenced-from-a-static">What is the reason behind &ldquo;non-static method cannot be referenced from a static context&rdquo;?</a>  </p>
  </blockquote>
  
  
  
  <p>I have the following method: </p>
  
  <pre><code>public void fillMachine(Game game)
  {
    // Colours of balls are evenly spread between these colours,
    // in ascending order.
    Color [] colourGroupColours
      = new Color [] {Color.red, Color.orange, Color.yellow,
                    Color.green, Color.blue, Color.pink,
                    Color.magenta};
    // This happiness change will show up when the GUI is added.
  
    Color ballColour;
    int noOfBalls = game.getMachineSize();
    for (int count = 1; count &lt;= noOfBalls; count++)
    {
      // The colour group is a number from 0
      // to the number of colour groups - 1.
      // For the nth ball, we take the fraction
      // (n - 1) divided by the number of balls
      // and multiply that by the number of groups.
      int colourGroup = (int) ((count - 1.0) / (double) noOfBalls
                             * (double) colourGroupColours.length);
      ballColour = colourGroupColours[colourGroup];
      game.machineAddBall(makeNewBall(count, ballColour));
    } // for
  
    } // fillMachine
  </code></pre>
  
  <p>In the main class I have <code>fillMachine(game1);</code></p>
  
  <p>I am getting the error: <code>non-static method fillMachine(Game) cannot be referenced from a static context
      fillMachine(game1);</code></p>
  
  <p>I'm not sure how to fix this though.</p>