简体   繁体   中英

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

Integer.toHexString(int);

应该是你要找的

String digits = "0123456789ABCDEF";

output = digits.charAt(remain) + output;

I hope there are no convertion problems.

我认为Integer.toHexString(int)是解决问题的最佳方法

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM