Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

(JAVA)Why we got an integer when we print number in hexadecimal notation?

enter image description hereExample:
sout(OxBD);
Output: 189

I don’t really understand why does compiler converts different representation of a number to integer. Why not boolean? When I try to cast to boolean I got an error, also don’t know why. With char it works.
I attached the photo below.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

"0xBD" is an integer, which explains why it’s converted to hexadecimal by Java. You can’t convert to boolean, as 189 isn’t something that can be converted to boolean (which can store only two values, 0 and 1).

189 can be stored as a char though; what you get is the ASCII character representation of 189.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading