Computing.Net > Forums > Programming > Java-Cannot convert double to class

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Java-Cannot convert double to class

Reply to Message Icon

Name: Dado
Date: February 14, 2005 at 15:25:49 Pacific
OS: WinXP
CPU/Ram: 1GB
Comment:

I created a method for adding complex numbers that should return a value of type NameOfaClass. I also have two instance variables declared of type double (real and imaginary). The method is called from another class.:
public NameOfaClass sum(NameOfaClass number)
{
NameOfaClass somevalue = number;
return (somevalue.real+this.real)+(somevalue.imaginary+this.imaginary);
}
I get an error however saying that a double type cannot be converted to NameOfaClass type. Can anyone suggest how I could calculate this and return a value of type NameOfaClass? Do I need to create a new object of type NameOfaClass and somehow return the desired value? Help is greatly appreciated!



Sponsored Link
Ads by Google

Response Number 1
Name: Dado
Date: February 14, 2005 at 18:29:42 Pacific
Reply:

Already figured it out. I created a new object of the class and returned it directly.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Java-Cannot convert double to class

C++ HELP! Convert double to int??? www.computing.net/answers/programming/c-help-convert-double-to-int/12281.html

Convert int to Char c++ www.computing.net/answers/programming/convert-int-to-char-c/12549.html

Java Temperature Converter www.computing.net/answers/programming/java-temperature-converter/13171.html