MessageFormat用法
String result=MessageFormat.format("select * from t_table where id={0} and name={1}","1","abc");
//result结果
select * from t_table where id=1 and name=abc
但是MessageFormat支持“”但不支持‘符号比如
String result=MessageFormat.format("select * from t_table where id={0} and name=’{1}‘","1","abc");
所以如果我们需要拼接sql语句可以使用String.format()方法
String.format用法
String result=String.format("String result=MessageFormat.format("select * from t_table where id='%s' and name='%s');","1","abc");
//result结果
select * from t_table where id=’1‘ and name=’abc‘