I tried the same code by replacing default values in the code below, I got '-1'. But the actual output is '1'. How???
int i = (byte) + (char) - (int) + (long) - 1;
System.out.println(i);
I tried the same code by replacing default values in the code below, I got '-1'. But the actual output is '1'. How???
int i = (byte) + (char) - (int) + (long) - 1;
System.out.println(i);
i
will be evaluated as (+(-(+(-1)))
, which will be evaluated as (-(-1))
, which is 1
.