LINUKS BLOG

Make progress is the topic for ever...

My Photo
Name:
Location: China

It's a fans of computer/ Computer is my favorite/ Making progress is the topic for ever...

Friday, January 26, 2007

double与Double的区别

double与Double的区别
double num;
Double num;
Double.parseDouble(num);
If you write the program as the third line,it will appear error.
答复一:
found : double
required: java.lang.Double

Double num1,num2,product;//double num1,num2,product;

答复二:
Double是一个类型类(对应double基本类型的类),而double则是一个基本类型。Double.parseDouble(s1);的结果返回的是一个double类型的值,你把一个double类型的值赋予Double类型的变量,在JDK1.4的环境下,这是不允许的。如果在1.5环境下,则是一个合法的赋值。但建议不要这么做。这样容易引起混淆。你可能是在JDK1.4的环境下进行编译的。你应该把Double和double分清。

--
Right or wrong decide by yourself, praise or blame listen to the others;
gain or loss placid as usual, success or failure return to the zero.

0 Comments:

Post a Comment

<< Home