aspose file tools*
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
Author

Int can not be dereferenced

Jean Perry
Greenhorn

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
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

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

James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

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

Joined: Mar 12, 2013
Posts: 6
I see... thank you
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Int can not be dereferenced