使用System.out.printf()的优点和缺点; [英] Advantages and Disadvantages of using System.out.printf();
问题描述
我只是想知道使用 System.out.printf();
的优点和缺点是什么?我们通常使用 System.out.println ();
或 System.out.print();
但是如果我们使用 System.out会有所不同.printf();
?使用 System.out.printf();
或任何其他打印语句是否有特定的缺点或优势?
I was just wondering what were the advantages and disadvantages of using System.out.printf();
We normally use System.out.println();
or System.out.print();
but will it make a difference if we use System.out.printf();
? Is there a specific disadvantage or advantage to using System.out.printf();
or any other print statements?
谢谢。
编辑:是的,我知道printf和println之间的区别。
Yes, I do know the difference between printf and println.
推荐答案
Printf允许特殊格式化:
Printf allows special formatting:
http://java.sun.com/developer/technicalArticles/Programming/sprintf/
这是优势。否则就像现在一样调用print()没有缺点。
That is the advantage. Otherwise there is no disadvantage to calling print() as you do now.
这篇关于使用System.out.printf()的优点和缺点;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!