在开发过程中,我们经常需要将一个字符串插入这个字符串中间,到底插入那个位置呢?这时候占位符就派上用场了
import java.text.MessageFormat;
public class TestMessageFormat {
public static void main(String[] args) {
String str = "Package under internal review, type: {0}. Processing time: 3 business days";
String [] person={"teather"};
String string =MessageFormat.format(str , person);
System.out.println(string);
}
}
输出结果:Package under internal review, type: teather. Processing time: 3 business days
import java.text.MessageFormat;
public class TestMessageFormat {
public static void main(String[] args) {
String str = "Package under internal review, type: {0},{1}. Processing time: 3 business days";
String [] person={"teather","student"};
String string =MessageFormat.format(str , person);
System.out.println(string);
}
}
输出结果:Package under internal review, type: teather,student. Processing time: 3 business days
|