Weird java behavior with casts to primitive types

It’s being parsed as this:

long i = (byte)( +(char)( -(int)( +(long)(-1) ) ) );

where all the + and - operators are unary + or -.

In which case, the 1 gets negated twice, so it prints out as a 1.

Leave a Comment