1
公共类Hexcolor {转换串色( “0x5b9f18”)在Java hexcolor
public static void main(String[] args) {
String a="0x5b9f18";
String hexColor = String.format("#%06X", a);
System.out.println(hexColor);
}
}
错误消息
异常在线程 “主” java.util.IllegalFormatConversionException:X != java.lang.String at java.util.Formatter $ FormatSpecifier.failConversion(Unknown Source) at java.util.Formatter $ FormatSpecifier.printInteger(Unknown Source) at java.util.Formatter $ FormatSpec ifier.print(未知源) at java.util.Formatter.format(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.lang.String.format(Unknown Source) at Hexcolor。主(Hexcolor.java:6)
非常感谢你。第二个建议对我有用。 – eagerToLearn