java的HashMap遍历输出

package hashmap_1;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// HashMap<String,double> hashMap = new
		// HashMap<String,double>();///Syntax error on token "double",
		// Dimensions expected after this token
		HashMap<String, Double> hashMap = new HashMap<String, Double>();
		hashMap.put("aa", 90.0);
		hashMap.put("bb", 80.0);
		hashMap.put("cc", 70.0);
		Iterator iter = hashMap.entrySet().iterator();
		while (iter.hasNext()) {
			Map.Entry entry = (Map.Entry) iter.next();
			Object key = entry.getKey();
			Object value = entry.getValue();
			System.out.println(key + ":" + value);

		}

	}

}

aa:90.0

bb:80.0

cc:70.0

    原文作者:二十六画生的博客
    原文地址: https://blog.csdn.net/u010002184/article/details/50735679
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞