1
我有这样的代码,我想,如下所示格式化输出,但是当我启动程序,达到对printf,它停止并给出错误Exception in thread "main" java.util.IllegalFormatConversionException: f != java.lang.String
用printf
variables:
itemcode=integer
selecteditems=string
perkg=double
userkg=string
quantity-integer
dry=string
total=double
格式化输出的java注意:这些是for循环的可变变量。
System.out.printf("%-4d %-13s %8.2f %8.2f %-8d %-10s %8.2f %n", itemcode,
selecteditems, per_kg, userkg, quantity, dry, total);
这将有助于了解这些变量的值和类型的 – 2014-10-07 17:07:54
可能重复(http://stackoverflow.com/questions/11936327/why-am-i-receiving-illegalformatconversionexception-in-java-for-this-code) – 2014-10-07 17:10:13
为什么'%n'作为最后的格式说明符? – Rustam 2014-10-07 17:11:24