I was observing today that by writing the below line in a simple java class
System.out.println(010|4);
gives the output of ’12’ , whats the logic behind that, please advise.
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.
|is the bitwise inclusive OR operator,010is octal for8, which is1000in binary,4is100in binary, so when you or each bit in1000with the corresponding bit in0100you get1100in binary which is12.