• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

int can not be dereferenced error

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.




 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
heh, guess you're right on that .

this is the line that is getting the errror
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because i thought that compares references and not values??
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic