Click here to watch in Youtube :
https://www.youtube.com/watch?v=PH-f0jqK0Bs&list=UUhwKlOVR041tngjerWxVccw
LinkedHashMapExample.java
Output
https://www.youtube.com/watch?v=PH-f0jqK0Bs&list=UUhwKlOVR041tngjerWxVccw
LinkedHashMapExample.java
import java.util.LinkedHashMap; /* * Example of containsKey(Object key) method. */ public class LinkedHashMapExample { public static void main( String[] args ) { LinkedHashMap<Integer, String> linkedHashMap = new LinkedHashMap<Integer, String>(); linkedHashMap.put(1, "Apple"); linkedHashMap.put(3, "Cat"); linkedHashMap.put(2, "Ball"); System.out.println("linkedHashMap : " + linkedHashMap+"\n"); /* * Returns true if this map contains a mapping for the specified key. */ boolean isKeyExist = linkedHashMap.containsKey(1); System.out.println("isKey '1' Exist : " + isKeyExist); isKeyExist = linkedHashMap.containsKey(10); System.out.println("isKey '10' Exist : " + isKeyExist); } }
linkedHashMap : {1=Apple, 3=Cat, 2=Ball} isKey '1' Exist : true isKey '10' Exist : false
https://sites.google.com/site/javaee4321/java-collections/LinkedHashMapDemoContainsKey.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment