我有一个字符串,其中包含像 {0}、{1} ... {n} 这样的表达式。我有长度为 n 的字符串列表。{0} 替换为 param[0],{1} 替换为 param[1],{n} 替换为 param[n]。我怎样才能做到这一点?
List<String> params = new ArrayList<String>;
param[0] = "dortmund";
param[1] = "5555";
String message = "customers address is {0}, phone number is {1}, please check them.";