+2 votes
66 views
asked in JAVA by (3.1k points)
Hi

        How to convert hex format into integer,string etc?

1 Answer

0 votes
answered by (8.2k points)

hi

How to convert from decimal to hex

String hexNumber = ...
int decimal = Integer.parseInt(hexNumber, 16);
System.out.println("Hex value is " + decimal);

How to convert from decimal to hex

int i = ...
String hex = Integer.toHexString(i);
System.out.println("Hex value is " + hex);

How to convert a long to and from hex

In case you need it, the Long class has Long.parseLong() and Long.toHexString() analogous to the Integer methods above.

Categories

...