String Arrays Java

String array cannot hold numbers or vice- versa. Jsp arrays can only store the type of data specified at the time of declaring the array variable. An array is a type of container which can hold a fixed number of values of a single type.

String Arrays Java

String Arrays Java

        

String array cannot hold numbers or vice- versa. Jsp arrays can only store the type of data specified at the time of declaring the array variable. An array is a type of container which can hold a fixed number of values of a single type. Array is a collection of similar data types. It means if you have declared an array as string then it can only store the string values. The length of an array is established when an array is created. After creation of the length, its length can't be changed.

The code of the program is given below:

<%
   String[] country = {"India", "Russia", "America", "England", "Ireland", "Germany"};
   %>
   <body>
   <center>
   <h1>
   <%for (int i = 0; i < country.length; i++) {
  out.print("<p>" + country[i] + "</p>");
   }

%>
<h1>
</center>
</body>

The output of the program is given below:

Download this example: