int s=0;
s+=Math.pow(2,3);
this line does not show possible lossy conversion whereas
int s=0
s=s+Math.pow(2,3)
the above line shows error. Any reason for this?
int s=0;
s+=Math.pow(2,3);
this line does not show possible lossy conversion whereas
int s=0
s=s+Math.pow(2,3)
the above line shows error. Any reason for this?
The problem is due to the method signature for Math.pow;. It returns the result as a double. You then attempte to return the double as an int, and that is a lossy conversion.