Sunday, November 25, 2012

Demo on ForEach loop in collections

import java.util.*;
class TestForEach
{
    public static void main(String[] args)
    {
        ArrayList<Integer> al=new ArrayList<Integer>();
        al.add(10);
        al.add(20);
        al.add(30);
        al.add(40);
        Iterator it=new Iterator();
        while(it.hasNext())
        {
            System.out.println(it.next());
        }
    }
}   

1 comment:

  1. Great insights. I look forward to reading what you're planning on next, because your post is a nice read.

    runkeeper

    ReplyDelete