• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

int can not be dereferenced error

 
Vee Shall
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.




 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be helpful to point out the line getting the error.
 
Vee Shall
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
heh, guess you're right on that .

this is the line that is getting the errror
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're treating a primitive like an object--why not just say r1 == r2???
 
Vee Shall
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because i thought that compares references and not values??
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic