img
Specifier
Effect
Causes the e symbol that indicates the exponent to be displayed in uppercase.
%E
Causes the e symbol that indicates the exponent to be displayed in uppercase.
%G
Causes the hexadecimal digits a through f to be displayed in uppercase as A
%H
through F.
%S
Uppercases the corresponding string.
%T
Causes all alphabetical output to be displayed in uppercase.
Causes the hexadecimal digits a through f to be displayed in uppercase as A
%X
through F. Also, the optional prefix 0x is displayed as 0X, if present.
For example, this call:
fmt.format("%X", 250);
creates this string:
FA
This call:
fmt.format("%E", 123.1234);
creates this string:
1.231234E+02
Using an Argument Index
Formatter includes a very useful feature that lets you specify the argument to which a format
specifier applies. Normally, format specifiers and arguments are matched in order, from left
to right. That is, the first format specifier matches the first argument, the second format
specifier matches the second argument, and so on. However, by using an argument index,
you can explicitly control which argument a format specifier matches.
An argument index immediately follows the % in a format specifier. It has the following
format:
n$
where n is the index of the desired argument, beginning with 1. For example, consider this
example:
fmt.format("%3$d %1$d %2$d", 10, 20, 30);
It produces this string:
30 10 20
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home