无法解除引用

-1 java

以下代码:

age.equals( otherPerson.age );
Run Code Online (Sandbox Code Playgroud)

产生编译错误,如:

Cannot be dereferenced.

我该如何解决?

pst*_*ton 5

it's hard to tell from your minimalistic question, but i'll guess that age is a primitive and therefore doesn't have any methods.

try using age == otherPerson.age instead.