它的工作是这样的
someUtility.replace(你好,我的名字是{1}什么是您的{2}?,马,名);
解决方案
的String.format(你好,我的名字是%1 $ S。你什么%的2 $ s吗? ,马克,名);
如果你只是为了使用各一次:
的String.format(你好,我的名字是%S什么是您%s的?,马,名);
It would work something like this
someUtility.replace ("Hello, my name is {1}. What is your {2}?", "Mark", "name");
解决方案
String.format("Hello, my name is %1$s. What is your %2$s?", "Mark", "name");
or if you will just use each once in order:
String.format("Hello, my name is %s. What is your %s?", "Mark", "name");