package com; import java.util.HashMap; import java.util.Map; import java.util.Set; public class Display { public static void main(String[] args) { Display Ctest = new Display(); String name = "fandunyang"; String college = "NanChangHangKongDaXue"; String Home = "JiangXiXingGuo"; HashMap<String,String> map = new HashMap(); map.put("myName", name); map.put("myCollege", college); map.put("myHome", Home); Ctest.test(map); } public void test(Map<String,String> parameters){ Set set = parameters.entrySet(); Map.Entry[] entries = (Map.Entry[])set.toArray(new Map.Entry[set.size()]); for (int i=0;i<entries.length;i++){ System.out.println("Key:"+entries[i].getKey().toString()); System.out.println("Value:"+entries[i].getValue().toString()); } } }
时间: 2024-10-29 02:23:54