字符串模版:把参考{0},{1}的值用数组的值来替换
import java.text.MessageFormat;
// 输出:参数0:参数0的值,参数1:参数1的值,参数2:参数2的值
MessageFormat.format("参数0:{0},参数1:{1},参数2:{2}", new Object[] { "参数0的值", "参数1的值", "参数2的值" })
// 输出:Once upon a time (2011-9-1, around about 下午4:32), there was a humble developer named Geppetto who slaved for 4 days with 21% complete user requirements.
String message = "Once upon a time ({1,date}, around about {1,time,short}), there "
+ "was a humble developer named Geppetto who slaved for "
+ "{0,number,integer} days with {2,number,percent} complete user " + "requirements. ";
Object[] variables = new Object[] { new Integer(4), new Date(), new Double(0.21) };
String output = MessageFormat.format(message, variables);