Advantages and Disadvantages of using System.out.printf();

后端 未结 2 1939
闹比i
闹比i 2021-01-14 12:02

I was just wondering what were the advantages and disadvantages of using System.out.printf(); We normally use System.out.println(); or System

相关标签:
2条回答
  • 2021-01-14 12:33

    Printf allows special formatting:

    http://java.sun.com/developer/technicalArticles/Programming/sprintf/

    That is the advantage. Otherwise there is no disadvantage to calling print() as you do now.

    0 讨论(0)
  • 2021-01-14 12:42

    Look at the JavaDoc of the class PrintStream. There you can see that the print / println methods print a String and printf is

    • A convenience method to write a formatted string to this output stream
    • using the specified format string and arguments.
    0 讨论(0)
提交回复
热议问题