The moose likes Java in General and the fly likes Java Double cannot be dereferenced Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Java Double cannot be dereferenced" Watch "Java Double cannot be dereferenced" New topic
Author

Java Double cannot be dereferenced

Megan Hart
Greenhorn

Joined: Dec 08, 2010
Posts: 6
Hi All, I am very new to Java and I am getting a 'Double cannot be dereferenced' error when I try to compile this code.

public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if (source == exitButton)
System.exit(0);
else if (source == calculateButton)
{
double sideAValue = Double.parseDouble(sideAField.getText());
double sideBValue = Double.parseDouble(sideBField.getText());

double sideCValue = Math.hypot(sideAValue, sideBValue);
sideCValue.setText(Double.toString(sideCValue));

The above section of code is part of a larger program that calculates the hypotenuse of a right triangle when the user enters the two smaller sides.

The error comes from this line of code:
sideCValue.setText(Double.toString(sideCValue));

Could someone please help me to know how to fix this?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14685
    
  16

Shouldn't that be


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14685
    
  16

And welcome to the ranch Next time you want to post some code, don't forget to UseCodeTags. This will be make it easier to read.
Megan Hart
Greenhorn

Joined: Dec 08, 2010
Posts: 6
Yes it should be! Thanks for alerting me to that error. I will be sure to use code tags next time around! Thanks for the welcome!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Java Double cannot be dereferenced
 
Similar Threads
Double compiler error - Help!
Double compiler error - Help!
creating a new JPanel from another JPanel "choice" button
Help w/ Data Input Error
Not being able to compile