This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 2771
    
  10

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

James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 973
    
    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
 
Similar Threads
Requesting help in understanding questions asked for project. Code and details inside
Array and GUI
Help with homework please
char cannot be dereferenced
recursion find number of times int appears in array...