Thursday 7 July 2011

Using varargs
varargs allow you to pass more than one parameter to a function
example
class Example
{
pubic static void main(String args[])
{
Example ob=new Example();
ob.printNum(5,6,7);
ob.printNum(1,2,3,4);
}
void printNum(int... a)
{
int i;
for(i:a)
System.out.println(a);
}
}

No comments:

Post a Comment