Share on Google+Share on Google+

JSP List Size

Advertisement
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 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:

Advertisements

Advertisement

Posted on: February 4, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.

Discuss: JSP List Size  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0