• Post Reply Bookmark Topic Watch Topic
  • New Topic

Double compiler error - Help!

 
Antonios Hadjigeorgalis
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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.
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!