| 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
|
|
Shouldn't that be
|
[My Blog]
All roads lead to JavaRanch
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
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!
|
 |
 |
|
|
subject: Java Double cannot be dereferenced
|
|
|