int i = (byte) + (char) - (int) + (long) - 1; ^-------^--------^-------^ Type casting
+ - + - assigned the sign ( Unary Operators ), so - then + then - and finally + gives you 1 .
If we just ignore the cast type, we have (+(-(+(-(1)))))=1
Equivalent code:
long a = (long) - 1; int b = (int) + a; char c = (char) - b; int finalAns = (byte) + c; System.out.println(finalAns);
coder-croc
source share