Switch to full style
JSP Code Examples
Post a reply

JSP Passing Arrays to Methods

Thu Jan 15, 2009 11:17 pm

Example show how to pass arrays to a defined summation method in jsp (Java Server pages).

Code:
<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 0passedArray.length;i++) {
            
sum += passedArray[i];
        }
         
         return 
sum;
    }
    %>

    <%
        
int numbersArray[] = {-12, -345};

        
out.println("The Elements of array Are : ");
        for (
int i 0numbersArray.lengthi++) {
            
out.println("numbersArray[" "] = (" numbersArray[i] + " )<BR>");
        }
        
out.println("The result of sumation of all the array elements ...<BR>");
        
out.println(sumArray(numbersArray));
         
        }
    %>
  </
BODY>
</
HTML




Post a reply
  Related Posts  to : JSP Passing Arrays to Methods
 Passing arrays as function parameter in java     -  
 Array Passing     -  
 Passing a Reference Variable     -  
 Passing an Argument to a Function by Value     -  
 Passing Pointers to function example     -  
 passing string value from java to .exe file     -  
 Passing Enum as Type Parameter to method     -  
 Which methods is best for SEO?     -  
 What Are Constructor Methods?     -  
 Static Methods and Variables     -  

Topic Tags

Servlets/JSP