Friday, 9 June 2017

java - Reuse a parameter in 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



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?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...