Can somebody show me, how to declare function with variable number of parameters in Java? I want to provide method similar to C-language printf function.
Thanks in adavne!
M.
Thanks in adavne!
M.
import static java.lang.System.out;
public class VargArgs {
public static void main(String ... args) { //Can even use them here
myPrintf("one");
myPrintf("one", "two");
}
public static void myPrintf(String ... args) {
for(String s : args) {
out.println(s);
}
}
}
Comment