Below is code of printf() and format() methods present in java.io.PrintStream
public java.io.PrintStream printf(java.lang.String, java.lang.Object...);
public java.io.PrintStream printf(java.util.Locale, java.lang.String, java.lang.Object...);
public java.io.PrintStream format(java.lang.String, java.lang.Object...);
public java.io.PrintStream format(java.util.Locale, java.lang.String, java.lang.Object...);
These methods consist of two format parameters. But, when we pass a single argument to these methods and run the program, it ran successfully.
My question is where these methods are defined with single parameters similar to print() or println() methods as these methods consist of single parameter(defined in java.io.PrintStream).
I tried to execute following code and it is running fine.
public class FormatAndPrintf {
public static void main(String args[]){
System.out.printf("This is printed using printf() function.");
System.out.format("This is printed using format() function.");
System.out.println("++++++++++++++++++++++++++++++++++++++++==");
}
}