Demonstrates the VARARGS feature of java for variable arguments along with normal parameters.

Here we demonstrate how we can pass normal parameter along with varible arguments.

class VarExample

{ public void Test(String str, int ... arr)

{System.out.print(str + arr.length + "contents ");

for(int i : arr){

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

System.out.println();

}

public static void main(String a[])

{VarExample ve =new VarExample();

ve.Test("First argument",1);

ve.Test("Second argument", 11, 12,13);

ve.Test(" No variable arguments ");

}
}
Advertisements

2 thoughts on “Demonstrates the VARARGS feature of java for variable arguments along with normal parameters.

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