This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Int can not be dereferenced Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Int can not be dereferenced" Watch "Int can not be dereferenced" New topic

Int can not be dereferenced

Jean Perry

Joined: Mar 12, 2013
Posts: 6
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

Joined: Oct 01, 2001
Posts: 2901

You can't use .equals() (or .anything) on primitives like int. Line 7 should be:

James Boswell

Joined: Nov 09, 2011
Posts: 1051

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

Joined: Mar 12, 2013
Posts: 6
I see... thank you
I agree. Here's the link:
subject: Int can not be dereferenced
jQuery in Action, 3rd edition