Java generating Strings with placeholders
java, string, string-interpolation
Solution
See `String.format` method.
String s = "hello %s!";
s = String.format(s, "world");
assertEquals(s, "hello world!"); // should be true
Problem
I'm looking for something to achieve the following: ``` String s = "hello {}!"; s = generate(s, new Object[]{ "world" }); assertEquals(s, "hello world!"); // should be true ``` I could write it myself, but It seems to me that I saw a library once which did this, probably it was the slf4j logger, but I don't want to write log messages. I just want to generate strings. Do you know about a library which does this?