Professional Documents
Culture Documents
Program Logic
Formulation
using JAVA
LESSON 4-1
ROMMEL L. DORIN
Contents
Where:
• FormatString is a string that contains text,
special formatting specifiers, or both.
• ArgumentList is a list of zero or more additional
arguments, which will be formatted according to
the format specifiers listed in the format string.
Formatting Output
Example:
%f – is a format specifier.
f – for floating numbers( float, double)
d – for integer values
Format specifier - is a placeholder for a value that
will be inserted into the string when it is displayed.
Formatting Output
Example 1: %f
%f – is a format specifier.
Format specifier - is a placeholder for a value that
will be inserted into the string when it is displayed.
Formatting Output
Example 2: %f %f
Formatting Output
Syntax
The items that appear inside brackets are optional.
Output:
Formatting Output
Flags
Comma Separators
Output:
Formatting Output
Minimum Field Width
Sample Code:
Output:
Formatting Output
Combining Minimum Field Width
and precision
Sample Code:
Output:
Formatting Output
Precision
Sample Code:
Output:
Formatting Output
String.Format Method
Use to format strings in Joption -
MessageDialog
General Syntax:
Formatting Output
String.Format Method