开发者

printf and new line

I was expecting the \n to cause the next statement to be printed on a new line but it doesn't...

is my syntax wrong?

writer.printf(" |\t\t\t | Tax Credits\t%010.开发者_运维知识库2f |\n", taxCreds) ;

thanks

Baba


With Java printf, the newline is a conversion character so you need to use %n:

%n: Line separator, the result is the platform-specific line separator


Use %n instead. The API for PrintStream#printf will show this is so. Edit: actually this will direct you to the Formatter API where you will find that %n results in a system-specific new line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜