Uppercase Option
In this chapter you will learn:
- How and when to use Uppercase Option for Java Formatter
- How to uppercase hexadecimal
- How to uppercase e symbol
Uppercase Option and its effects
Uppercase versions format specifiers cause the conversion to use uppercase where appropriate.
Specifier | Effect |
---|---|
%A | Uppercase the hexadecimal digits a through f to A through F. Also, the prefix 0x is displayed as 0X, and the p will be displayed as P. |
%B | Uppercases the values true and false. |
%E | Uppercase the e symbol that indicates the exponent. |
%G | Uppercase the e symbol that indicates the exponent. |
%H | Uppercase the hexadecimal digits a through f to A through F. |
%S | Uppercases the corresponding string. |
%T | Uppercase alphabetical output. |
%X | Uppercase the hexadecimal digits a through f to A through F. Also, the optional prefix 0x is displayed as 0X, if present. |
uppercase hexadecimal
The following code outputs value in uppercase hexadecimal.
import java.util.Formatter;
/*from j a v a2s . co m*/
public class Main {
public static void main(String args[]) {
Formatter fmt = new Formatter();
fmt.format("%X", 250);
System.out.println(fmt);
}
}
The output:
uppercase e symbol
The following code does uppercase the e
symbol that indicates the exponent
import java.util.Formatter;
/* j a v a2 s . c o m*/
public class Main {
public static void main(String args[]) {
Formatter fmt = new Formatter();
fmt.format("%E", 123.1234);
System.out.println(fmt);
}
}
Next chapter...
What you will learn in the next chapter:
- Using an Argument Index
- How to reuse the parameter
- How to use relative index
- How to use relative index to create customized date format
Home » Java Tutorial » String