HashMapの初期化 †Map<String, String> hashMap = new HashMap<String, String>(){ { put("A", "a"); put("B", "b"); } }; HashMap値の修正 †Map map=new HashMap(); map.put("test1",1); map.put("test2",2); System.out.println(map.get("test2")); map.put("test2",3); System.out.println(map.get("test2")); アウトプット結果 2 3 HashMapの要素をリストする †Map<String, Label> map = new HashMap<String, Label>(); //... for ( String key : map.keySet() ) { } for ( Label value : map.values() ) { } for ( Map.Entry<String, Label> entry : map.entrySet() ) { String key = entry.getKey(); Label value = entry.getValue(); } 超多機能のアクセス解析が永久無料! コメント: |