Welcome to the Ranch
That is quite a difficult question.
As you know, “implicitly casting” means a widening conversion carried out automatically.
This Java® Language Specification (=JLS) section tells you about widening conversions, and
double→float isn't in there. You will find it in
this JLS section about narrowing conversions. But it doesn't tell you whether it can compile. You need
this section about assignments.
That JLS section wrote:In addition, if the expression is a constant expression (§15.28) of type byte, short, char, or int:
• A narrowing primitive conversion may be used if the variable is of type byte, short, or char, and the value of the constant expression is representable in the type of the variable.
• A narrowing primitive conversion followed by a boxing conversion may be used if the variable is of type Byte, Short, or Character, and the value of the constant expression is representable in the type byte, short, or char respectively.
The type of your first constant expression isn't
byte,
short,
char, or
int; It is
double, which means it doesn't fall in the scope of that section. So you cannot compile the assignment of a
double to a
float without an explicit
(float) cast.