If I’m not mistaken,
0.5are decimal numbers; thus, making it a float value.
You should not rely solely on your intuition when learning a new programming language.
0.5 is a
double literal. For a
float literal you need to write
As The Java Language Specification (JLS 3.10.2) states:
A floating-point literal is of type
floatif it is suffixed with an ASCII letter
f; otherwise its type is
doubleand it can optionally be suffixed with an ASCII letter