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.
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.
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