The following declaration gives me a compile-time error "Error:(19, 13) java: incompatible types: possible lossy conversion from double to int"
int i1 = 10.0;
// Error:(19, 14) java: incompatible types: possible lossy conversion from double to int
Question 1
I understand the error but can the compiler not infer - in this particular case - that there will be no loss of precision?
Question 2
If I explicitly convert the double to an int then it compiles fine (not even a warning) even though I am definitely losing precision in this example
int i2 = (int)9999999999999.999999999;
If I can't compile the first case - where no loss occurs - then why does this second example with the explicit conversion not even generate a compiler warning?