Java VarArgs - An Overlooked Feature
By admin on Jan 26, 2008 in Java, Programming
I think VarArgs feature available since JDK1.5 is often overlooked by developer. It is handly when you want to pass multiple arguments of the same types to a function.
E.g.
public class TestArgs { public void print(String... text){ for (String val:text){ System.out.println(val); } } public static void main(String args[]){ TestArgs arg = new TestArgs(); arg.print("testing"); arg.print("testing", "testing"); arg.print("testing", "testing", "testing"); } }
Post a Comment