Programmers that are familiar with other programming languages (such as C, C++, or Perl) are used to working with a print method known as "printf". The formatting styles of this method are reusable between languages, including Java.
A simple formatting for the "printf" method is shown below:
System.out.printf("The %s has %s, %d of them!", "dog", "fleas", 5);
In Java, this same style of formatting used with "printf" appears in the format method:
System.out.format("The %s has %s, %d of them!", "dog", "fleas", 5);
The printf method is seen by some programmers as simply a "convenience" for C/C++ programmers who are programming in Java. The format method is thought of as a more Java-like choice.
This site will be using the format method. See more information about using this method at Formatting Output. |