The following code does as you require.
public class Logger {
public static void main(String[] args) {
new Logger().info("Info: param1 is ?, param2 is ?", new String[] { "a", "b" });
new Logger().info("Info: param1 is ?, param2 is ?", "a", "b");
}
public void info(final String message, final String... args) {
System.out.printf(message.replace("?", "%s") + "%n", args);
}
}
However, you should consider using correct formatting place-holders instead of '?'. For instance:
public class Logger {
public static void main(String[] args) {
new Logger().info("Info: param1 is %s, param2 is %s", new String[] { "a", "b" });
new Logger().info("Info: param1 is %s, param2 is %s", "a", "b");
}
public void info(final String message, final String... args) {
System.out.printf(message + "%n", args);
}
}
Both versions will print:
Info: param1 is a, param2 is b
Info: param1 is a, param2 is b