Because otherwise it defaults to double
, which is a more commonly used floating point type than float
.
From the Java Language Specification, section 3.10.2:
A floating-point literal is of type float if it is suffixed with an ASCII letter F or f; otherwise its type is double and it can optionally be suffixed with an ASCII letter D or d (§4.2.3).
(Personally I'd rather there were no default, to make it clear in all cases, but that's a different matter.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…