int cannot be dereferenced

后端 未结 3 865
谎友^
谎友^ 2020-11-30 15:19

I am beginning in java (I\'m learning in microedition) and I got this error: \"int cannot be dereferenced\" in the following class:

class DCanvas extends Can         


        
3条回答
  •  囚心锁ツ
    2020-11-30 15:33

    You are calling the setColor and fillRect methods on g, which is a parameter of type int.
    Since int is not a reference type, you cannot call methods on it.

    You probably want to add a Graphics parameter to the function.

提交回复
热议问题