Collection Interface size() Method

Collection Interface size() Method


Posted in : Java Posted on : November 25, 2010 at 12:04 PM Comments : [ 0 ]

This method is use to find out number of elements held in the invoking collection.

Collection Interface size() Method:

This method is use to find out number of elements held in the invoking collection.

Syntax :

    int size();

Example :

import java.util.ArrayList;
import java.util.List;
import java.util.Collection;

public class CollectionInterfaceSizeMethod {

public static void main(String[] args) {
  Collection collection = new ArrayList();
  collection.add("Ankit");
  collection.add("Ravi");
  collection.add("Deepak");
  collection.add("Raj");
  collection.add("Kumar");
  collection.add("Jitendra");
  
  int listsize = collection.size();
  System.out.println("Size = " + listsize);
  }
}

Output :

Size = 6

Download This example code

Go to Topic «PreviousHomeNext»

Your Comment:


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

 
Tutorial Topics