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:

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: String Arrays Java View All Comments
Post your Comment