This method returns the Iterator of a passed map instance - Java java.util

Java examples for java.util:Map Operation

Description

This method returns the Iterator of a passed map instance

Demo Code


//package com.java2s;
import java.util.Iterator;

import java.util.Map;
import java.util.Set;

public class Main {
    /**/* w  ww . j av a 2s .com*/
     * <p>
     * This method returns the <tt>Iterator</tt> of a passed map instance
     * </p>
     * 
     * @param mapObj
     *       A map instance whose iterator needs to be returned
     * 
     * @return
     *       an instance of <tt>Iterator</tt>
     */
    public static Iterator<? extends Object> getIteratorForMap(
            Map<? extends Object, ? extends Object> mapObj) {
        Set<? extends Object> keySet = mapObj.keySet();

        return keySet.iterator();
    }
}

Related Tutorials