Passing Arrays to Methods
<HTML> <HEAD> <TITLE>Passing Arrays to Methods</TITLE> </HEAD> <BODY> <H1>Passing Arrays to Methods</H1> <%! 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...<BR>"); for (int i = 0; i < array.length; i++) { out.println("array[" + i + "] = " + array[i] + "<BR>"); } doubler(array); out.println("After the call to doubler...<BR>"); for (int i = 0; i < array.length; i++) { out.println("array[" + i + "] = " + array[i] + "<BR>"); } %> </BODY> </HTML>
1. | Define function | ||
2. | Passing the out Object to a Method | ||
3. | Using Recursion | ||
4. | Declaring Multiple Methods | ||
5. | Creating a Method |