Take these two snippet for example:
Case 1:
Scanner s = new Scanner(System.in);
int n = s.nextInt(); /** take user input **/
n *= Double.NEGATIVE_INFINITY;
and
Case 2:
int k=10;
double kk = 10.10;
int rst = k*kk;
In both the cases, I am not doing any typecasting from my side, but Case 1 executes and prints value of n
correctly but Case 2 throws an error, can not convert from double to int
. Why this difference?