• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Int can not be dereferenced

 
Jean Perry
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, just working with an array search for a specific item. They array is populated by people object with data member "name" and "phone number" I used a getter (getPhoneNumber which returns an int) method to return the phone number. when I go to compile its giving me a

"int can not be dereferenced" error

can someone explain what that is? and why my code is creating that error?



 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use .equals() (or .anything) on primitives like int. Line 7 should be:

 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The variable number is an int which is not an object but a primitive type. Hence, you cannot apply the equals method to it.
 
Jean Perry
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see... thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic