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
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"
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
Summary: Use the NumberFormat class. All the documentation is in the java api here. A more simple but less elegant solution would be to convert the number to a Double (wrapper class) then use the toString me...
Summary: I have a question about the main function in Java. The main funciton in Java is a static function, so you can't call non-static functions inside a static one. But if you create an object of the instan...
Summary: Is there a funtion to get just the current time as a string? Here is what I have now userName and date are defined at the beggining of the class): public void sendMessage(String mes) { ...