-1
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?

Turing85
  • 18,217
  • 7
  • 33
  • 58

1 Answers1

0

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.

Keyvan Soleimani
  • 606
  • 2
  • 4
  • 16