Check if a particular key exists in LinkedHashMap in Java
Description
The following code shows how to check if a particular key exists in LinkedHashMap.
Example
//from w w w . j ava 2 s .c o m
import java.util.LinkedHashMap;
public class Main {
public static void main(String[] args) {
LinkedHashMap<String,String> lHashMap = new LinkedHashMap<String,String>();
lHashMap.put("1", "One");
lHashMap.put("2", "Two");
lHashMap.put("3", "Three");
boolean blnExists = lHashMap.containsKey("3");
System.out.println(blnExists);
}
}
The code above generates the following result.