Computing.Net > Forums > Programming > Quick JAVA question

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.

Quick JAVA question

Reply to Message Icon

Name: Fedor
Date: September 11, 2003 at 17:05:49 Pacific
OS: win98
CPU/Ram: 256
Comment:

Hi,

I am trying to add two doubles, but i am getting this error when i compile:

"operator + cannot be applied to java.lang.Double, java.lang.Double"

Does anyone know how to fix this?

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Razvan
Date: September 12, 2003 at 02:53:54 Pacific
Reply:

Well, that's because the java operators like +,-,*,etc... operates only on the primitives data types like "double","int","float",etc.. You cannot make addition operations on objects because the operators overloading is missing in Java,unlike C++.
These two data types double and java.lang.Double are different types.


0

Response Number 2
Name: gpp
Date: September 12, 2003 at 11:25:34 Pacific
Reply:

you can use the doubleValue() method to get the primative 'double' value from it..


0

Response Number 3
Name: SN
Date: September 12, 2003 at 11:47:01 Pacific
Reply:

alternatively, you can declare the doubles with a lowercase d rather than uppercase. Depends on what else you're doing with them.
-SN


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


IE settings perl output



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: Quick JAVA question

Quick Java Question www.computing.net/answers/programming/quick-java-question/3555.html

Java question www.computing.net/answers/programming/java-question/8649.html

Easy java question www.computing.net/answers/programming/easy-java-question/9284.html