File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 2968

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
It's not a secret anymore!