What will b return ?
byte b = (byte)0x8A;
System.out.println("Value"+b);
What will it print? And when does the value will return a negation?
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.
Probably not what you expect. In Java a
byteis a (signed) number not a character, so when0x8Ais converted to a String you will get the decimal representation of a small negative number.So I’d expect:
If you wanted
0x8Ato be interpreted as a character you should write this:But that doesn’t really work either because the Unicode codepoint 008A is not a printing character. (And for what it is worth, 0x8A is not ASCII because true ASCII is a 7 bit character set.)