 <p>This</p> <pre><code>System.out.printf("\n%-5s%-5s%-15s%-15s%-6s%-15s%-5d\n", "Sno.","B.No.","BOOK-NAME","AUTHOR-NAME","COPIES","PUBLISHER","PRICE"); </code></pre> <p>will not work because the last is a number and you pass it the string "PRICE".</p> <p>You should use different format string for the columns names.</p> <p>Column names : <code>"\n%-5s%-5s%-15s%-15s%-6s%-15s%-5s\n"</code></p>