0

So basically it doesn't allow me to compile, the error message is in Chinese so I cannot show it to you guys. But heres the codes:

public static void main (String[] args){
int[] fiveDice=new int[5];


roll(fiveDice);

}

void roll(int[] dice){
  for(int i=0;i<5;i++){
   dice[i]= (int)(Math.random()*6+1);
  }

so on the line "roll(fiveDice)", it occurs an error. I had tried "roll(fiveDice[])" and it shows me another error.

  • 3
    your `roll`-method is not `static`! – luk2302 Nov 28 '16 at 17:43
  • 2
    You need to read the error, try to make sense of it, google it if you're not sure. Don't try random fixes. And if you're really stuck and you ask a question here, post the exact and complete error message. But this question is being asked twice a day, so finding a duplicate is easy. – JB Nizet Nov 28 '16 at 17:43
  • 1
    You can't call a non-static method by a static method (main method). But as luk2302 mentioned, the kind of error would help to solve your problem – endkugelfang Nov 28 '16 at 17:44
  • `roll`method needs to be declared as `static`. You cannot access non-static members from static `main` method. – slawekpl Nov 28 '16 at 17:46

0 Answers0