About 51 results
Open links in new tab
  1. Java Hashmap: How to get key from value? - Stack Overflow

    Sep 6, 2009 · If I have the value "foo", and a HashMap<String> ftw for which ftw.containsValue("foo") returns true, how can I get the corresponding key? Do I have to loop through the hashmap? What is …

  2. Get keys from HashMap in Java - Stack Overflow

    May 5, 2012 · 1 To get keys in HashMap, We have keySet () method which is present in java.util.Hashmap package. ex :

  3. java - Correct way to initialize HashMap and can HashMap hold …

    A HashMap can hold any object as a value, even if it is another HashMap. Eclipse is suggesting that you declare the types because that is the recommended practice for Collections. under Java 5.

  4. What are the differences between a HashMap and a Hashtable in Java?

    HashTable and HashMap are member of the Java Collections Framework (since Java 2 platform v1.2, HashTable was retrofitted to implement the Map interface). HashTable is considered legacy code, …

  5. java - How to update a value, given a key in a hashmap? - Stack Overflow

    805 Suppose we have a HashMap<String, Integer> in Java. How do I update (increment) the integer-value of the string-key for each existence of the string I find? One could remove and reenter the pair, …

  6. java - Difference between HashSet and HashMap? - Stack Overflow

    Apart from the fact that HashSet does not allow duplicate values, what is the difference between HashMap and HashSet in their implementation? It's a little bit vague because both use hash tables to...

  7. java - How to directly initialize a HashMap (in a literal way)? - Stack ...

    Map<String, String> myMap = new HashMap<String, String>() {{ put("a", "b"); put("c", "d"); }}; However, the anonymous subclass might introduce unwanted behavior in some cases. This includes for …

  8. java - How to for each the hashmap? - Stack Overflow

    300 Lambda Expression Java 8 In Java 1.8 (Java 8) this has become lot easier by using forEach method from Aggregate operations (Stream operations) that looks similar to iterators from Iterable …

  9. HashMap in Java - Stack Overflow

    May 29, 2013 · HashMap, as the name implies, groups the keys into buckets based on the keys' hashcode (). But the default hashcode does not match for two instances of MyInt with the same value.

  10. java - Searching for a Value in a HashMap - Stack Overflow

    Searching for a Value in a HashMap Asked 10 years, 3 months ago Modified 10 years, 3 months ago Viewed 15k times