我想将 int 数字格式化为十六进制字符串。 System.out.println(Integer.toHexString(1)); 打印 1 但我希望它为 0x00000001。我该怎么做?
System.out.println(Integer.toHexString(1));
1
0x00000001
最佳答案
试试这个
System.out.println(String.format("0x%08X", 1));
https://stackoverflow.com/questions/13851743/
相关文章:
c# - 如何在 C# 中将 int 格式化为货币?
javascript - 使用javascript将小数位添加到数字中
c# - 在c#中格式化日期
html - 在 Vim 中格式化和缩进 HTML
eclipse - 如何防止 Eclipse 格式化程序弄乱带有文本符号的注释?
c# - 是否有一种文化安全的方法来获取带前导零的 ToShortDateString() 和 To
ruby-on-rails - 格式化时间戳
java - 如何在 Java 中使用 String.format()?
php - php中的PDF导出
javascript - 阻止 ReSharper 将 JavaScript 函数参数放入新行