Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 2
LinkedHashMap | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 17
LinkedHashMap
LinkedHashMapはMapインターフェースを実装したクラスで、キーの挿入順を保持します。
キーを昇順にするのはTreeMapで、LinkedHashMapはキーの挿入順を保持し、同一キーを再挿入してもキーの挿入じゅんは保持されるのが特徴です。
getすると、putした順番で値が返ります。

以下、サンプルです。

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        Map map = new LinkedHashMap();
        map.put("key1","test1");
        map.put("key3","test3");
        map.put("key2","test2");
        map.put("key3","test4");// 再挿入(上書き)
        
        StringBuffer buf = new StringBuffer();
        
        for (Iterator itr = map.keySet().iterator();itr.hasNext();){
            String key   = (String)itr.next();
            String value = (String)map.get(key);
            System.out.println(key +" = " + value);
        }
    }
}
実行結果は以下のようになります。

key1 = test1
key3 = test4
key2 = test2

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 87

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 87

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 96

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/map/linkedhashmap/linkedhashmap.html on line 96