That works fine because you are implicitly performing a widening primitive conversion from int
to float
and long
respectively.
However this would not compile and you would need to add an f
or a L
to make it work:
float f = 1.0; //can't convert from double to float
long l = 12345678912; //12345678912 is not a valid int