Friday, June 7, 2019

Java: Why doesn't (int) += (double) cause a "incompatible types" error?

Here's an oddity:



float a = 0;
a = a + Math.PI; // ERROR


and yet:



a += Math.PI; // OK!



even this works:



int b = 0;
b += Math.PI; // OK, too!


Why does the += operator allow lossy implicit type conversions?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...