集册 Java实例教程 遍历LinkedHashMap的值

遍历LinkedHashMap的值

欢马劈雪     最近更新时间:2020-01-02 10:19:05

411
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
遍历LinkedHashMap的值


import java.util.Collection;

import java.util.LinkedHashMap;

import java.util.Iterator;
/*来自 
 nowjava.com - 时  代  Java*/

 

public class Main {

 

  public static void main(String[] args) {

   

    LinkedHashMap lHashMap = new LinkedHashMap();

   

    //add key value pairs to LinkedHashMap

    lHashMap.put("1","One");

    lHashMap.put("2","Two");

    lHashMap.put("3","Three");

   

    Collection c = lHashMap.values();

   

    //obtain an Iterator for Collection
    /** from 
    N  o w  J a v a . c o m**/

    Iterator itr = c.iterator
展开阅读全文