Passing Arrays to Methods
Passing Arrays to Methods
<%!
void doubler(int a)
{
for (int i = 0; i < a.length;i++) {
a[ i ] *= 2;
}
}
%>
<%
int array[] = {1, 2, 3, 4, 5};
out.println("Before the call to doubler...
");
for (int i = 0; i < array.length; i++) {
out.println("array[" + i + "] = " + array[i] + "
");
}
doubler(array);
out.println("After the call to doubler...
");
for (int i = 0; i < array.length; i++) {
out.println("array[" + i + "] = " +
array[i] + "
");
}
%>