Generics and Collections: ArrayList : Generic Collections « Generics « Java Tutorial

import java.util.ArrayList;
import java.util.Iterator;

public class MainClass { 
  public static void main(String args[]) {
    ArrayList<String> list = new ArrayList<String>();

    Iterator<String> itr = list.iterator();

    while(itr.hasNext()) {
      String str =;

      System.out.println(str + " is " + str.length() + " chars long.");
one is 3 chars long.
two is 3 chars long.
three is 5 chars long.
four is 4 chars long.

12.2.Generic Collections
12.2.1.Generics and Collections: ArrayList
12.2.2.Arrays: Storing class objects in Array as data items
12.2.3.Using Generic Comparable interface
12.2.4.A generic first-in, first-out bounded collection of objects
12.2.5.A list declared to hold objects of a type T can also hold objects that extend from T.
12.2.6.Utilities for generic ArrayList
12.2.7.Your own tree with generic user object
12.2.8.Generic to list
12.2.9.Create a typesafe copy of a raw list.
12.2.10.Create a typesafe copy of a raw map.
12.2.11.Create a typesafe filter of an unchecked iterator.
12.2.12.Create a typesafe view over an underlying raw set.
12.2.13.Create a typesafe view over an underlying raw map.
12.2.14.Create a typesafe filter of an unchecked enumeration.