Thi*_*ndu 1 java floating-point double
在下面的代码中,我们构建了一些Double
来自变量double
,float
和String
.但是,根据文档,Double
只有构造函数接受double
和String
- 而不是float
.那么这段代码是如何编译的呢?
Double d1 = new Double(2.5);
Double d2 = new Double(2.5f); //Why can I pass a float here?
Double d3 = new Double("2.5");
Run Code Online (Sandbox Code Playgroud)