Possible Duplicate:
What is the reason behind “non-static method cannot be referenced from a static context”?Нестационарный метод не может ссылаться на статический контекст?
У меня есть следующий метод:
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 <= 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
В главном классе у меня есть fillMachine(game1);
я получаю ошибку: non-static method fillMachine(Game) cannot be referenced from a static context fillMachine(game1);
я не уверен, как это исправить это все же.
Есть вопрос здесь? – ewok
добавить статику к вашему методу – VirtualTroll