Home Tutorial Java Iterator Iterator Java Size

 
 

Share on Google+Share on Google+
Iterator Java Size
Posted on: November 4, 2009 at 12:00 AM
Advertisement
In this section of tutorial we will learn how to use the size() method in context of Iterator. We will create an example to display the contents of the ArrayList using size() method.

  • The Java Iterator size() is the method of the collection Interface.
  • It is implemented in all collection classes.
  • It returns the no of elements present in the collection.


Java Size Iterator Example
import java.util.*;

public class size {

	public static void main(String[] args) {
		List list = new ArrayList();
		String country[] = { "India", "Japan", "USA", "UK", "Nepal" };
		for (int i = 0; i < 5; i++) {
			list.add(country[i]);
		}
		Iterator i = list.iterator();
		int x = 0;
		while (x






					
					
Advertisement

Related Tags for Iterator Java Size:


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.

Posted on: November 4, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com