This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes int can not be dereferenced error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "int can not be dereferenced error" Watch "int can not be dereferenced error" New topic
Author

int can not be dereferenced error

Vee Shall
Greenhorn

Joined: Apr 03, 2010
Posts: 7
Hi;
working with fractions which i absolutely hate ( ).........uggh but anywhoo. i'm getting a "int can not be derreferenced" error but i don't see why. All i'm doing is comparing to values to see if they are equal. I'm not using a pointer. What can i do to correct this?

here is my code.






Being a scholar of life does not require a student loan.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

It might be helpful to point out the line getting the error.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vee Shall
Greenhorn

Joined: Apr 03, 2010
Posts: 7
heh, guess you're right on that .

this is the line that is getting the errror
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're treating a primitive like an object--why not just say r1 == r2???
Vee Shall
Greenhorn

Joined: Apr 03, 2010
Posts: 7
because i thought that compares references and not values??
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Vee Shall wrote:because i thought that compares references and not values??


True, for reference variables. But are we dealing with reference variables or primitive variables here?
Vee Shall
Greenhorn

Joined: Apr 03, 2010
Posts: 7
umm..........i don't think so??? (of course i'm new to java so i could definately be wrong)
i guess i'm not sure.
Muneeswaran Balasubramanian
Ranch Hand

Joined: Mar 19, 2010
Posts: 138
Hi Vee,
Your code convention is wonderful.You wrote the code as a great developer.
Come to the point,
Stein and david are correct.You are treat the primitives as a values and
with out reference of class RationalNumber how can you call the method of the RationalNumber.
so try to access the methods like reciprocal... by using the object of RationalNumber


Cheers Munees
My Blog
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: int can not be dereferenced error
 
Similar Threads
Help with error in running program
Help on understanding this code
Adding instances of a class
can object has multiple values
non-static method construction