Click here to watch in Youtube :
https://www.youtube.com/watch?v=qxAp7sEVqRY&list=UUhwKlOVR041tngjerWxVccw
LinkedHashMapExample.java
Output
https://www.youtube.com/watch?v=qxAp7sEVqRY&list=UUhwKlOVR041tngjerWxVccw
LinkedHashMapExample.java
import java.util.LinkedHashMap; import java.util.TreeMap; /* * Example of LinkedHashMap(Map<? extends K,? extends V> m) Constructor. */ public class LinkedHashMapExample { public static void main( String[] args ) { TreeMap<Integer, String> treeMap = new TreeMap<Integer, String>(); treeMap.put(1, "Apple"); treeMap.put(3, "Cat"); treeMap.put(2, "Ball"); System.out.println("treeMap : " + treeMap+"\n"); /* * Constructs an insertion-ordered LinkedHashMap instance with the same * mappings as the specified map. The LinkedHashMap instance is created * with a default load factor (0.75) and an initial capacity sufficient * to hold the mappings in the specified map. */ LinkedHashMap<Integer, String> linkedHashMap = new LinkedHashMap<Integer, String>( treeMap); System.out.println("linkedHashMap : " + linkedHashMap); } }
treeMap : {1=Apple, 2=Ball, 3=Cat} linkedHashMap : {1=Apple, 2=Ball, 3=Cat}
https://sites.google.com/site/javaee4321/java-collections/LinkedHashMapDemoConsAcceptsMap.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment