JSP List Size

JSP List Size is used to get the size of the list. The JSP List Size uses array list object to add the elements and finally return the number of elements are added to the list.

JSP List Size

JSP List Size

        

JSP List Size is used to get the size of the list. The JSP List Size uses array list object to add the elements and finally return the number of elements are added to the list. 

Understand with Example

In this section, you will learn how to get the list size. You can see in the given example that we have import the package java.util.* to create a list of countries using the class List and ArrayList. The method l.size() of class List will return the size of the created list. Finally the out.print ln print the size of elements in the array.

l.size : The method returns the size list of the elements added to an array object. 

Here is the code of listSize.jsp

<%@ page import="java.util.*" %>
<%
List l = new ArrayList();
l.add("India");
l.add("USA");
l.add("China");
l.add("Japan");
l.add("England");
out.println("The Length of List is: ");
int i=l.size();
out.println(i);
%>

Output will be displayed as:

Download Source Code: