• 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

Double compiler error - Help!

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope this is the correct forum for this question...

a_bid.setText(price.toString);

a_bid is a Jlabel
price is a Double value

Why would this produce a compiler error:

double cannot be dereferenced
if (field==1) {a_bid.setText(price.toString());}
^

I'm just learning Java and I can;t find any info on what dereferenced means.
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post more of the code. Use the code tags.

It looks like the problem might be with the 'field' variable.

This should probably have been posted in the Java in General (Beginner) forum.
[ January 10, 2005: Message edited by: Steven Bell ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

To "dereference" something in Java always means to write it followed by a dot (.). You dereference something to access one of its members, either a method or a field. Primitives like int, boolean, char, and yes, double, can't be dereferenced, because they have no members.

There are only two things dereferenced on that line: a_bid and price. I'm betting that price is not a Double (with a capital "D") but a double (with a small "d"). A Double is an object, and Double variables can, indeed, be dereferenced. A double is a primitive type and cannot. Double check your declarations and pay attention to capitalization!

This belongs in our "Java in General (Beginner)" forum, not in this one, which is for discussing specialized Java APIs. I'm going to move this post to that forum, where you can continue the discussion.
 
Antonios Hadjigeorgalis
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot. I forgot about the Double object versus the double primitive, that fixed it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic