本文介绍了双字段类型声明为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下零双重变量声明之间有什么显着的区别:
0.0 VS 0d

What is significant difference between following zero double variable declaration:0.0 VS 0d

double d1 = 0.0;
double d2 = 0d;

我知道这两个都比只是 0 ,因为对于代码阅读器来说更为明显。

I understand that both these are better than just 0,because are more obvious for code reader.

但是 0.0 VS 0d 差异对我来说不清楚。

However 0.0 VS 0d difference is not clear for me.

推荐答案

没有区别。看看

There is no difference. Have a look at the Java Language Specification, section 3.10.2


  1. 数位。数位 ExponentPart FloatTypeSuffix

  2. 。数字ExponentPart FloatTypeSuffix

  3. 数字ExponentPart FloatTypeSuffix

  4. Digits ExponentPart FloatTypeSuffix

  1. Digits . Digits ExponentPart FloatTypeSuffix
  2. . Digits ExponentPart FloatTypeSuffix
  3. Digits ExponentPart FloatTypeSuffix
  4. Digits ExponentPart FloatTypeSuffix


...

f F d D



都是一个 DecimalFloatingPointLiteral ,第一个类型1,第二个类型4

Both are a DecimalFloatingPointLiteral, the first one type 1, the second one type 4

这篇关于双字段类型声明为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 10:12