Java, non-static cannot be reference to static context

后端 未结 2 954
旧时难觅i
旧时难觅i 2021-01-26 10:19

Doing Java course, at UNI atm, and I\'m having a bit of trouble with a dice-problem.

I have the following:

 public class Die {
   public int eyes;
   pri         


        
2条回答
  •  梦谈多话
    2021-01-26 11:11

    n is not a static variable, so you cannot refer to it in a static manner (Die.n).

    Since it is an instance variable in the Die class, and you are referring to it in the Die class, you can just use n instead of Die.n.

提交回复
热议问题