How do you know if a program runs correctly or not? You check the results, or the output of the program. Sometimes the output is data, sometimes the output is a pattern like a Christmas tree. When printing out data values, you might want to generate the output in a certain format. For instance, dollar values should always have 2 decimal places, $2 should be $2.00.
B. System.out.println(), System.out.print() and System.out.printf()
We know System.out.println() prints strings, values of expressions, or both.
System.out.print() is similar, but always prints on the same line
System.out.printf() allows you to "format" the output such as the number of decimal places. For instance, System.out.printf("%.2f", Math.PI) prints Pi value with two decimal places.