Is there any difference between PrintWriter.format and PrintWriter.printf? The printf api says, "An invocation of this method of the form out.printf(format, args) behaves in exactly the same way as the invocation out.format(format, args)." If this is the case, what's the point of having two methods that do the same thing?
System.out.printf() does not require the explicit creation of a Formatter.
I'm sometimes a little dense...can you spell this out for me? The two java.io.PrintWriter methods in question have the exact same signature:
public PrintWriter format(String format, Object... args) public PrintWriter printf(String format, Object... args)
And according to the javadocs, they do the same thing. How is one more convienent than the other? I'm not seeing how either requires the creation of a Formatter. Perhaps you thought I was talking about Formatter's format method.
Well, They wanted to add System.out.printf() to Java
the "out" in the System object is a PrintWriter. That is what they wanted, now the format() method was already in Java, and instead of removing it and breaking all the code written using the format method, then kept the format method for backwards compatibility. I do know they added the varagrs to the format method, but that will not break backwards compatibility.
To me, it looks like they both have the exact same results.