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));
正在找工作,欢迎发 JD 到我邮箱,坐标上海浦东新区。

浙公网安备 33010602011771号