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:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: int Array
Post your Comment