开发者

printf and new line

开发者 https://www.devze.com 2023-01-28 03:39 出处:网络
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?

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

精彩评论

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