System.out.printf vs System.out.format System.out.printf vs System.out.format java java

System.out.printf vs System.out.format


System.out is a PrintStream, and quoting the javadoc for PrintStream.printf

An invocation of this method of the form out.printf(l, format, args) behaves in exactly the same way as the invocation out.format(l, format, args)


The actual implementation of both printf overloaded forms

public PrintStream printf(Locale l, String format, Object ... args) {    return format(l, format, args);}

and

public PrintStream printf(String format, Object ... args) {        return format(format, args);}

uses the format method's overloaded forms

public PrintStream format(Locale l, String format, Object ... args)

and

public PrintStream format(String format, Object ... args)

respectively.


No difference.They both behave the same.