RSS Feed for This PostCurrent Article

Java VarArgs – An Overlooked Feature

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.


public class TestArgs {

    public void print(String... text){
        for (String val:text){

    public static void main(String args[]){
        TestArgs arg = new TestArgs();
        arg.print("testing", "testing");
        arg.print("testing", "testing", "testing");


Trackback URL

Sorry, comments for this entry are closed at this time.