Questions:Ask|Latest

 
 

Share on Google+Share on Google+

int Array

Advertisement
Array is a collection of same data type. Suppose if we have declared an array of type int then the array will take only the int values and not any other data types.

int Array 

        

Array is a collection of same data type. Suppose if we have declared an array of type int then the array will take only the int values and not any other data types. We can find find out the length of  the variable by using the variable length.  


The code of the program is given below:

<HTML>
  <HEAD>
    <TITLE>Using int Array in jsp</TITLE>
  </HEAD>
  <BODY>
  <table align="center" bgcolor="#CCFFFF" border="1">
 <tr><td><H3>Using int Array in jsp</H3></td></tr>
   <tr><td> 
       <%
        int array[] = {0, 2, 4, 8, 16}, sum = 0;
        for (int i = 0; i < array.length;i++){
		 
		 sum=sum+array[i];	        
		}
        out.println("The average = " + sum / array.length);
    %>
	</td></tr>
	</table>
  </BODY>
</HTML>

 

Output of  the Program:

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 12, 2008

Related Tutorials

Ask Questions?    Discuss: int Array  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com