Thu Jan 15, 2009 11:17 pm
<HTML>
<HEAD>
<TITLE>Passing Arrays to Methods</TITLE>
</HEAD>
<BODY>
<H1>Passing Arrays to Methods</H1>
<%!
int sumArray(int[] passedArray)
{
int sum=0;
for (int i = 0; i < passedArray.length;i++) {
sum += passedArray[i];
}
return sum;
}
%>
<%
int numbersArray[] = {-1, 2, -3, 4, 5};
out.println("The Elements of array Are : ");
for (int i = 0; i < numbersArray.length; i++) {
out.println("numbersArray[" + i + "] = (" + numbersArray[i] + " )<BR>");
}
out.println("The result of sumation of all the array elements ...<BR>");
out.println(sumArray(numbersArray));
}
%>
</BODY>
</HTML>
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.