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();

}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s