This week's giveaway is in the Java/Jakarta EE forum. We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line! See 2> Now if we change the code as follows: (true) ? b = b+1 : (b = 100) ; Again this is wrong as values must be assigned to a variable.
3> Now Mr Anton Uwe has changed the code as follows int vv; vv=(true) ? (b = b + 1) : (b = 100);
The above code will still generate error. The problem is in int he expression b = b + 1;
Here b is byte , when b+1 is executed the result converted to int type and int value can not be assigned to a byte as there is a loss of precision so we need explicit type casting.
so the expression: vv=(true) ? (b = (byte)(b + 1)) : (b = 100); or vv=(true) ? b = (byte)(b + 1) : (b = 100); are correct now.
posted 11 years ago
It is Miss Kasak Tahilramani NOT Mr Kasak Tahilramani....