Wondering if it is possible to combine both a single string and varargs string in a String.format(), like this:
String strFormat(String template, String str, String... moreStrs) {
return String.format(template, str, moreStrs);
}
If I call the above like this:
strFormat("%s/%s/%s", "hello", "world", "goodbye");
I get java.util.MissingFormatArgumentException: Format specifier 's'
This works:
String strFormat(String template, String... moreStrs) {
return String.format(template, moreStrs);
}
As well as this works:
String strFormat(String template, String str1, String str2) {
return String.format(template, str1, str2);
}
Is it possible to get this to work?
String strFormat(String template, String str, String... moreStrs) {
return String.format(template, str, moreStrs);
}
Thanks!
str
from the rest of the strings? Are you attempting to require at least onestr
to be passed? – Child