Formatting strings


The following format options can be used by System.out.printf() and String.format().
The exhausting documentation of format options can be found in the JavaDoc of the class java.util.Formatter.

Format Used for Explained in video*
%% percent character
%.2f floating point number with two decimal places Lesson 114
%c unicode character
%d integer number Lesson 116
%f floating point number Lesson 114
%g floating point number in scientific notation (f. e. 1.23E8)
%n line break Lesson 114
%s string
* Please buy the course Java for newcomers and log in to udemy.com to watch the explanation videos.