Demonstrates The overloading Varargs methods.

class VarArgs

{public void Test(int ... v)

{System.out.print("No. of args "+ v.length +"contents ");

for(int i : v)

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

System.out.println();

}

public void Test(boolean ... v)

{System.out.print("No. of args "+ v.length+"contents ");

for(boolean i: v)

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

System.out.println();

}

public void Test(String str, int ... v)

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

for(boolean i: v)

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

System.out.println();

}

public static void main(String a[])

{ VarArgs va = nwe VarArgs();

va.Test("Testing me:", 10, 20);

va.Test(11,12,13);

va.Test(true, false, false);

//va.Test();  // Error ambiguity between boolean and integer function

}

}
Advertisements

One thought on “Demonstrates The overloading Varargs methods.

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