Posts Tagged Varargs feature

Demonstrates the VARARGS feature of java for variable arguments.

This example shows how to use VARAGRS feature of java for variable length arguments instead of using array.

class VarExample

{

public void test(int ... arr)

{

System.out.print("No. of arguments "+arr.length+"contents ");

for(int i: arr)

{ System.out.print( i+ " ");

}

System.out.println();

}

public static void main(String a[])

{ VarExample ve= new varExample() ;

va.Test(10);

va.Test(11,12,13,14);

va.Test();

}
}

, ,

No Comments