JavaLeave
JavaLeave

Reputation: 233

Convert int to hex string need a better way

I am doing a method that can convert a int number to hexadecimal string. Basically my code is work for all test, but I am still looking for an efficient way to get rid of the array part. Anyone would give me a hand? the better way for not using array, but rather use a string type would be more efficient, and the answer is very clear as above. So i just delete my original code

Upvotes: 0

Views: 269

Answers (3)

user2745026
user2745026

Reputation: 1

I Think the Integer.toHexString(int) is the best way to fix your problem

Upvotes: 0

pinckerman
pinckerman

Reputation: 4213

String digits = "0123456789ABCDEF";

output = digits.charAt(remain) + output;

I hope there are no convertion problems.

Upvotes: 1

Toby L Welch-Richards
Toby L Welch-Richards

Reputation: 817

Integer.toHexString(int);

Should be what you are looking for

Upvotes: 2

Related Questions