|
Technical Interview Questions
Javascript Interview Questions
Oracle Interview Questions
J2EE Interview Questions
C++
Interview Questions
XML
Interview Questions
EJB
Interview Questions
JSP
Interview Questions
.........More
Programming Source Codes
Java Source Codes
Html Source Codes
CSS Source Codes
C Source Codes
.........More
Soft Skills
Communication Skills
Leadership Skills
.........More
|
|
Java Source Codes
Variable length Argument in
Java 1.5
/**
*
* @author jimmi.prajapati
*
*/
public class VarArgsExample {
int sumArrays(int[]... intArrays)
{
int sum, i, j;
sum=0;
for(i=0; i<intArrays.length; i++) {
for(j=0; j<intArrays[i].length; j++) {
sum += intArrays[i][j];
}
}
return(sum);
}
public static void main(String args[])
{
VarArgsExample va = new VarArgsExample();
int sum=0;
sum = va.sumArrays(new int[]{1,2,3},
new int[]{4,5,6},
new int[]{100,200});
System.out.println("The sum of the numbers is: " + sum);
}
}
<<<----- Return to
Java Source
Code Questions Page.
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Java Interview
Questions for more Java Interview Questions with answers
Check
Servlet Interview
Questions for more Servlet Interview Questions with answers
Check
Structs Interview
Questions for more Structs Interview Questions with answers
|