I know that when having to do with operators in Java , and different data types, then the result is promoting to the larger of the data types
So, because double is larger than float, when having for example
Arithmetic.java:26: error: incompatible types: possible lossy conversion from double to float
short x = 14;
float y = 13;
double z = 30;
System.out.println( x * y / z);
float w = 2.1; // error
By default, 2.1 is a Double literal.
Compiler wants an assurance from your side that you're ready to perform the narrowing conversion, that's why it expects a F (or f) after the literal.
If you don't put an
f), it will result in compilation error.
float y = 13; // works successfully.
Whereas, in the other case, 13 is an Integer literal. So, it easily gets into a float type. Therefore, the code works successfully.