当前位置: 动力学知识库 > 问答 > 编程问答 >

Format String Output Variable Java

问题描述:

I am trying to create my output to look like a table in Java. Is it possible to create a standard format that I use for all my output? So far I have?

String format = String.format("%-3s%-3s\n");

System.out.printf(format, "foo", "bar");

When I am currently trying this with different input and creating my format for use within a for loop I am getting an error saying:

Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '%-3s'

Any help is greatly appreciated.

分享给朋友:
您可能感兴趣的文章:
随机阅读: