Consider the following code:
class cast_unsafe{
static final float b = 0.75f;
void casting(){
int c = (int)(b);
}
}
Run it by the following command: javac -processor index cast_unsafe.java
Output:
cast_unsafe.java:4: warning: [cast.unsafe] "@DoubleVal(0.75) float" may not be casted to the type "@IntVal(0) int"
int c = (int)(b);
^
cast_unsafe.java:4: warning: [cast.unsafe] "@LowerBoundUnknown float" may not be casted to the type "@NonNegative int"
int c = (int)(b);
^
2 warnings
However, the cast is safe and c evaluates to 0.
Consider the following code:
Run it by the following command:
javac -processor index cast_unsafe.javaOutput:
However, the cast is safe and c evaluates to 0.