View RSS Feed

Advanced Java

Advanced Java programming.

  1. Iterating a Collection

    by , 02-18-2012 at 05:07 PM
    Collection’s all elements are iteration is done by getting an iterator from collection. Use the iterator through collection.

    It is explained by this given code:
    Java Code: This is the code to explain the collection iteration
    Collection myCollection = new HashSet();
    //... add elements to the collection
    Iterator iterator = myCollection.iterator();
        Object object =;
        //do something to object;    
    //You can also use the