javaprintfdifferenceprintlnsystem.out

What is the difference between System.out.printf and System.out.format specifically in Blue Java?


I've been watching a tutorial in Java and suddenly saw that the teacher is using System.out.format in the same way of using System.out.printf and is fetching the same results. So I'm a bit confused between the two.


Solution

  • A look at the documentation of printf reveils:

    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)

    Jumping into the printf method we see:

    return format(format, args);
    

    So printf is just another interface to call format()