System.out.printf和String.format之间的区别 [英] Difference between System.out.printf and String.format
本文介绍了System.out.printf和String.format之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以知道两者在Java中有什么区别吗?我正在读一本书,它同时使用两种方法来显示字符串.
May I know what is the difference between the two in java? I am reading a book and it uses both methods to display strings.
推荐答案
标准输出和
The first one writes to the stdout and the second one returns a String
object.
使用哪种取决于唯一目的.如果要在标准输出(控制台)中显示字符串,请使用第一个.如果要获取格式化字符串的句柄以在代码中进一步使用,请使用第二个.
Which to use depends on the sole purpose. If you want to display the string in the stdout (console), then use the first. If you want to get a handle to the formatted string to use further in the code, then use the second.
这篇关于System.out.printf和String.format之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文