About 51 results
Open links in new tab
  1. 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 :

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

  3. 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: …

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

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

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

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

  8. What is the difference between the HashMap and Map objects in Java?

    There is no difference between the objects; you have a HashMap<String, Object> in both cases. There is a difference in the interface you have to the object. In the first case, the interface is …

  9. Is a Java hashmap search really O (1)? - Stack Overflow

    For a hash table resolving collisions with chaining (like Java's hashmap) this is technically O (1+α) with a good hash function, where α is the table's load factor. Still constant as long as the number of objects …

  10. ¿Cual es la diferencia entre Map y HashMap en JAVA?

    May 12, 2017 · Luego, HashMap es tan solo una implementación (aunque probablemente la más común) de un Map de entre varias que son posibles . Otras implementaciones de Map son por …