Possible Duplicate:
Weird java behavior with casts to primitive types
Why following prints 1?
int i = (char) - (int) + (long) - 1;
System.out.println(i);
Why above lines of code prints 1? How come the value of i become 1?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I am not mistaken,
is actually equivalent to
since -1 and 1 fit nicely into all data types used in the expression, we can drop the casts to get