提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用参数索引重新排序输出。
public class Main /** from * NowJava.com - 时 代 Java **/ { public static void main(String[] args) { System.out.printf( "Parameter list without reordering: %s %s %s %s\n", "first", "second", "third", "fourth"); System.out.printf( "Parameter list after reordering: %4$s %3$s %2$s %1$s\n", "first", "second", "third", "fourth"); } }