It would work something like this
someUtility.replace ("Hello, my name is {1}. What is your {2}?", "Mark", "name");
Thanks in advance!
It would work something like this
someUtility.replace ("Hello, my name is {1}. What is your {2}?", "Mark", "name");
Thanks in advance!
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");
If you want to use Spring the Resource Bundles will give you the actual exact style of replacement that you have displayed. You can see some examples here: http://www.mkyong.com/spring/spring-resource-bundle-with-resourcebundlemessagesource-example/
Look at MessageFormat:
MessageFormat.format("Hello, my name is {0}. What is your {1}?", "Mark", "name");
Usually I prefer String.format
or System.out.printf
though for c-style formatting (sort of), as Matthew suggested.