java java中printf和println的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28758636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
difference between printf and println in java?
提问by Bhargav Modi
Just came to know that javadoes has a method named printf, then what is the difference between printf& println?
才知道java确实有个方法叫printf,那么printf& 有println什么区别呢?
回答by Ryan Shukis
System.out.println();is efficient for simply printing a line of text. If the line of text needs to be formatted (ex: alignment (left-justified, etc.), etc.), then System.out.printf();would be used.
System.out.println();对于简单地打印一行文本是有效的。如果需要格式化文本行(例如:对齐(左对齐等)等),则将System.out.printf();使用。
Check out this linkfor more information.
查看此链接了解更多信息。

