-3
void catalog()
{
System.out.printf("\n%-5s%-5s%-15s%-15s%-6s%-15s%-5d\n",
"Sno.","B.No.","BOOK-NAME","AUTHOR-NAME","COPIES","PUBLISHER","PRICE");
for(int i=1;i<53;i++)
System.out.print("-");
System.out.println();
for(int i=0;i<nob;i++)
System.out.printf("%-5d%-5d%-15s%-15s%-5d%-10s%-10d\n",
(i+1),bno[i],bname[i],author[i],availcopies[i],publisher[i],price[i]);
for(int i=1;i<53;i++)
System.out.print("-");
System.out.println();
}
我有在Java中使用的printf這個問題,所以這是錯誤我用的printf得到的Java printf的幫助中格式化
java.util.MissingFormatArgumentException: Format specifier '%-15s'
at java.util.Formatter.format(Formatter.java:2519)
at java.io.PrintStream.format(PrintStream.java:970)
at java.io.PrintStream.printf(PrintStream.java:871)
at Library.catalog(LibrarySystem.java:162)
at LibrarySystem.main(LibrarySystem.java:218)
你想要做什麼? –
我想打印一張表,列出數組的細節 –
嘗試使用' - %s'而不是'%-s' –