What is significant difference between following zero double variable declaration:
0.0
VS 0d
double d1 = 0.0;
double d2 = 0d;
I understand that both these are better than just 0
,because are more obvious for code reader.
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
DecimalFloatingPointLiteral:
Digits . Digits
optExponentPart
optFloatTypeSuffix
opt. Digits ExponentPart
optFloatTypeSuffix
optDigits ExponentPart FloatTypeSuffix
optDigits ExponentPart
optFloatTypeSuffix
...
FloatTypeSuffix: one of
f F d D
Both are a DecimalFloatingPointLiteral
, the first one type 1, the second one type 4