Program to demonstrate how Variable Arguments List (Varargs) works in Java.
package varargs; public class VarargsTest { public static void varargs( Object ... objects ) { System.out.println("The Class name of objects is : " + objects.getClass().getName() ); System.out.println("The length of objects is : " + objects.length ); for(int i = 0; i < objects.length; i++) { System.out.println("The value of objects : "+ objects[i]+" "); } System.out.println(); } public static void main(String... args) { int day = 6; String month = "May"; int year = 1986; args = new String[5]; Object[] date = {day,month,year}; varargs(); varargs(day); varargs(day,month); varargs(day,month,year); varargs(date); varargs((Object) date); varargs(new Object[] {date}); varargs(args); varargs((Object) args); varargs((new Object[]{args} )); } }Output of the program :