Sat Aug 22, 2009 4:15 pm
public class VariableArg {
public static void main(String args[])
{
int output = sum(1,2,4,5,1,3);
System.out.println("Sum = "+output);
}
public static int sum(int ... x)
{
int result =0 ;
for (int i=0;i<x.length;i++)
{
result+=x[i];
}
return result;
}
}
Sum = 16
Wed Nov 30, 2011 6:21 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.