I have a template string
str = "Hello %s, your name is %s, %s 's born in 1990."
Run Code Online (Sandbox Code Playgroud)
I want to format this string, as below: Hello Mr.P, your name is Mr.P, Mr.P 's born in 1990. I can do the following below:
String.format(str, "Mr.P","Mr.P","Mr.P");
Run Code Online (Sandbox Code Playgroud)
产生以上。还有什么其他方式可以格式化字符串,而不必重复与n参数相同的值次数
java ×1