Java UnknownFormatConversionException='';
你们能帮我找到错误的位置吗 错误: 下面是我的一段代码,我认为错误是:Java UnknownFormatConversionException='';,java,Java,你们能帮我找到错误的位置吗 错误: 下面是我的一段代码,我认为错误是: while(Character.toUpperCase(proceed) == 'Y') { System.out.printf("%nFARIYTALE SWEETS" + "%n%n1. Arabian Nights Chocolate Coins - 1 lb. Bag %5s%,7.2f"
while(Character.toUpperCase(proceed) == 'Y')
{
System.out.printf("%nFARIYTALE SWEETS"
+ "%n%n1. Arabian Nights Chocolate Coins - 1 lb. Bag %5s%,7.2f"
+ "%n2. Beauty and the Beast Lollipops - 1 lb. Bag %,12,2f"
+ "%n3. Mad Hatter Jelly Beans - 1 lb. Bag %,20.2f"
+ "%n4. Pinocchio's Candy Cones - Each %,23.2f"
+ "%n5. Sleeping Beauty Caramel Apples - Each %,17.2f"
+ "%n%nEnter your choice: ", "$", 2.25, 2.50, 1.75, 0.75, 1.25);
} //END while
应该是
"%n2. Beauty and the Beast Lollipops - 1 lb. Bag %,12.2f"
(
%,12.2f
和not%,12,2f
)调试提示:从格式字符串中删除所有转换,然后逐个重新添加。第一个触发异常的是错误的异常。然后仔细查看它,找到打字错误(,
vs,
)这就是修复方法。谢谢你,伙计。
"%n2. Beauty and the Beast Lollipops - 1 lb. Bag %,12,2f"
"%n2. Beauty and the Beast Lollipops - 1 lb. Bag %,12.2f"