Link to home
Start Free TrialLog in
Avatar of ted_driver
ted_driver

asked on

How to print a Hex Value

This site's search engine doesn't seem to be working right now......this question may have been asked before.
I want to calculate a number, an int and display it as a hexadecimal value to the screen.  How is this done?

Example:
int  test = 0XFF;
System.out.println(test); // prints 255,  I want to print FF

I would also like to be able to print the binary equivalent, can this be done also?
Avatar of Tom7
Tom7

Have a look at the static method

Integer.toHexString(int i)

which returns a String.

Cheers Tom


ASKER CERTIFIED SOLUTION
Avatar of imladris
imladris
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ted_driver

ASKER

Works Great!  Just what I was looking for...
Thanks!