In Java, suppose we have a function with the parameter double a. Does it work if I pass an integer as argument? (I mean, is there an implicit conversion?) And in the opposite case: if I have e.g. an integer as parameter, and I pass a double?
Unluckily, I am not able to compile my code at the moment, and I would like to check this assert.
Thank you for your attention.
See JLS – Section # 5.3 for details on
Method Invocation Conversion.So, your first invocation(
inttodouble) will work fine according to rule # 2.But the second invocation(
doubletoint) will give Compiler Error, according to the statement quoted further in the same section: –