Java – why must the float value be declared twice?

I'm confused why floating point values must be declared as in any other value, but they must be declared before the value

Example: floating point z = (floating point) 10.5;

Why can't we declare floating point values as;

Example: floating point number Z = 10.5;

http://prntscr.com/a3c7i7

Solution

Because 10.5 is a double, it cannot be implicitly converted to floating

Float z = 10.5f;
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>