public double delhi(Integer a)
{
return (int)a;
}
In case you do not get it, look at the return type of the method
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The return type declared on a method is used to allocate a memory on the stack to store the return value. Here, by declaring return type as
doublecompiler will allocate more space (64-bit) than required by the actual return value, anint(32-bit). Therefore, there is no loss of data expected on this(up)conversion. Therfore, both compiler and runtime, does not complain and it works. Try the opposite, set return type asintand return alongordouble. You will get compiler error because there will be potential of data corruption.