Results 1 to 1 of 1
Thread: VarArgs Example
-
VarArgs Example
Java Code: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); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks