int t = 5;
System.out.printf("%3x ",t);
String outString = String.format("%d",t);
编译不过,它参数一定要object 型,我现在想格式输出。比如c语言里的printf("%5x",t);
怎么解决啊?
在线等。
System.out.printf("%3x ",t);
String outString = String.format("%d",t);
编译不过,它参数一定要object 型,我现在想格式输出。比如c语言里的printf("%5x",t);
怎么解决啊?
在线等。
DecimalFormat dataFormat = new DecimalFormat("000");
System.out.println(dataFormat.format(t));
DecimalFormat 是十进制,不能做八进制或十六机制的格式准换吧。cocosunshine老兄: 我用的api就是1.5的。
System.out.printf(outString); 测试没有问题可能是你的版本不对吧检查一下你的IDE用的JDK的版本
System.out.printf("%3x ",t); 首先t是int型数据,是最原始数据类型
不是Object
你要把int数据转换成Integer再输出
System.out.printf("%3x ",new Integer(i)); //这样试试吧