重用String.format中的参数? [英] Reuse a parameter in String.format?
本文介绍了重用String.format中的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
String hello = "Hello";
String.format("%s %s %s %s %s %s", hello, hello, hello, hello, hello, hello);
hello hello hello hello hello hello
在对format方法的调用中是否需要多次重复hello变量,还是有一个速记版本可以让您一次指定参数以应用于所有%s
标记?
Does the hello variable need to be repeated multiple times in the call to the format method or is there a shorthand version that lets you specify the argument once to be applied to all of the %s
tokens?
推荐答案
查看全文