java测试代码如下:
import java.text.MessageFormat;
public class DemoMessageFormat {
public static void main(String[] args) {
String fmtMsg0= MessageFormat.format("Hello,{0}", "Jerry","Shirley");
String fmtMsg1= MessageFormat.format("Hello,{1}", "Jerry","Shirley");
System.out.println("fmtMsg0= "+fmtMsg0);
System.out.println("fmtMsg1= "+fmtMsg1);
}
}
程序执行结果:
fmtMsg0= Hello,Jerry
fmtMsg1= Hello,Shirley