About 3,490,000 results
Open links in new tab
  1. java - Iterate through a HashMap - Stack Overflow

    Jul 1, 2009 · Since all maps in Java implement the Map interface, the following techniques will work for any map implementation (HashMap, TreeMap, LinkedHashMap, Hashtable, etc.) Method #1: …

  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. Get the highest values in a hashmap in java - Stack Overflow

    Get the highest values in a hashmap in java [duplicate] Asked 7 years, 9 months ago Modified 3 years, 5 months ago Viewed 40k times

  5. java - How to get values and keys from HashMap? - Stack Overflow

    Apr 27, 2013 · Convert Hashmap to MapSet to get set of entries in Map with entryset() method.: Set st = map.entrySet(); Get the iterator of this set: Iterator it = st.iterator(); Get Map.Entry from the iterator: …

  6. 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 …

  7. java - Key existence check in HashMap - Stack Overflow

    Is checking for key existence in HashMap always necessary? I have a HashMap with say a 1000 entries and I am looking at improving the efficiency. If the HashMap is being accessed very frequently, ...

  8. 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, …

  9. 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 …

  10. 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 …