Java Code Examples for java.util.LinkedHashMap#containsValue()
The following examples show how to use
java.util.LinkedHashMap#containsValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckValueOfLinkedHashMapExample.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public static void main(String[] args) { //create LinkedHashMap object LinkedHashMap lHashMap = new LinkedHashMap(); //add key value pairs to LinkedHashMap lHashMap.put("1", "One"); lHashMap.put("2", "Two"); lHashMap.put("3", "Three"); /* To check whether a particular value exists in LinkedHashMap use boolean containsValue(Object key) method of LinkedHashMap class. It returns true if the value is mapped to one or more keys in the LinkedHashMap otherwise false. */ boolean blnExists = lHashMap.containsValue("Two"); System.out.println("Two exists in LinkedHashMap ? : " + blnExists); }
Example 2
Source File: CheckValueOfLinkedHashMapExample.java From javaide with GNU General Public License v3.0 | 6 votes |
public static void main(String[] args) { //create LinkedHashMap object LinkedHashMap lHashMap = new LinkedHashMap(); //add key value pairs to LinkedHashMap lHashMap.put("1", "One"); lHashMap.put("2", "Two"); lHashMap.put("3", "Three"); /* To check whether a particular value exists in LinkedHashMap use boolean containsValue(Object key) method of LinkedHashMap class. It returns true if the value is mapped to one or more keys in the LinkedHashMap otherwise false. */ boolean blnExists = lHashMap.containsValue("Two"); System.out.println("Two exists in LinkedHashMap ? : " + blnExists); }
Example 3
Source File: JZUtils.java From JZVideoDemo with MIT License | 5 votes |
public static boolean dataSourceObjectsContainsUri(Object[] dataSourceObjects, Object object) { LinkedHashMap<String, Object> map = (LinkedHashMap) dataSourceObjects[0]; if (map != null && object != null) { return map.containsValue(object); } return false; }
Example 4
Source File: SerialHasher.java From JavaSCR with MIT License | 5 votes |
public static void main(String[] args) throws IOException, ClassNotFoundException { MyKey key = new MyKey(1); LinkedHashMap<MyKey, String> ht = new LinkedHashMap<>(); ht.put(key, "Value"); System.out.println("Entry: " + ht.get(key)); // Retrieve using the key, works // Serialize the hash table object try (FileOutputStream fos = new FileOutputStream("hashdata.ser"); ObjectOutputStream oos = new ObjectOutputStream(fos)) { oos.writeObject(ht); } // Deserialize the hash table object LinkedHashMap<MyKey, String> ht_in; try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream("hashdata.ser"))) { ht_in = (LinkedHashMap <MyKey, String>) ois.readObject(); } if (ht_in.containsValue("Value")) // Check whether the object actually exists in the hash table System.out.println("Value was found in deserialized object."); // Can fail after serialization and deserialization. Consequently, // it may be impossible to retrieve the value of the object after // deserialization by using the original key. if (ht_in.get(key) == null) // Gets printed System.out.println("Object was not found when retrieved using the key."); }