Java String format() method

format() method returns a formatted String based on the given locale,specified format and arguments.

Syntax:

Parameter:

locale :  It specifies locale value to be applied on the format() method.

format: It specifies the format of the output String

args : It specifies the number of arguments for the format String.It may    be zero or more

Returns:

It returns a formatted String

Java String format() Example 1      

Output:

Java String format() Example 2

Output:

Java String format() Example 3      

Output:

Java String format() Example 4      

Output:

Leave a Comment