java tutorial wrote:Floating-Point Literals
A floating-point literal is of type float if it ends with the letter F or f; otherwise its type is double and it can optionally end with the letter D or d.
The floating point types (float and double) can also be expressed using E or e (for scientific notation), F or f (32-bit float literal) and D or d (64-bit double literal; this is the default and by convention is omitted).
You're litterally trying to put a 64bit data into a 32 bit data type. That's why it's complaining.
It's actually related to the reason float num = 9.0; won't work. Since floating point literals in Java are double and double is wider than float, then you need a narrowing conversion instead, to make a double fit into a float which Java won't do automatically.