Java使用占位符输出
printf
String str="World!";
System.out.printf("Hello,%s",str);
%1$s占位符
String str = "World!";
System.out.println(String.format("Hello,%1$s", str));
{}占位符
String str0 = "World!";
String str1 = "I love Java...";
System.out.println(MessageFormat.format("Hello,{0}{1}", str0, str1));
摘抄自网络,便于检索查找。

浙公网安备 33010602011771号