This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 2833
    
  11

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

James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Int can not be dereferenced
 
Similar Threads
recursion find number of times int appears in array...
Requesting help in understanding questions asked for project. Code and details inside
char cannot be dereferenced
Array and GUI
Help with homework please