是.您可以定义参数的索引,请参阅API的Argument Index部分.
例如:
// ? argument 3 (1-indexed)
// | ? type of String
// | | ? argument 2
// | | | ? type of decimal integer
// | | | | ? argument 1
// | | | | | ? type of decimal number (float)
// | | | | | |
System.out.printf("%3$s %2$d %1$f", 1.5f, 42, "foo");
Run Code Online (Sandbox Code Playgroud)
产量
foo 42 1.500000
Run Code Online (Sandbox Code Playgroud)
注意
以下习语都共享相同的格式定义:
String#formatPrintStream#printfFormatter#format| 归档时间: |
|
| 查看次数: |
1905 次 |
| 最近记录: |