About 359,000 results
Open links in new tab
  1. Java HashMap - W3Schools

    A HashMap however, store items in "key/value" pairs, and you can access them by an index of another type (e.g. a String). One object is used as a key (index) to another object (value). It can store different types: String keys and Integer values, or …

  2. Map (Java Platform SE 8 ) - Oracle Help Center

    An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. This interface takes the place of the Dictionary class, which was a totally abstract class rather than an interface.

  3. HashMap in Java - GeeksforGeeks

    Mar 7, 2025 · In Java, HashMap is part of the Java Collections Framework and is found in the java.util package. It provides the basic implementation of the Map interface in Java. HashMap stores data in (key, value) pairs. Each key is associated with a value, and you can access the value by using the corresponding

  4. Get keys from HashMap in Java - Stack Overflow

    May 5, 2012 · To get keys in HashMap, We have keySet() method which is present in java.util.Hashmap package. ex : Map<String,String> map = new Hashmap<String,String>(); map.put("key1","value1"); map.put("key2","value2"); // Now to get keys we can use keySet() on map object Set<String> keys = map.keySet();

  5. Map Interface in Java - GeeksforGeeks

    Jan 9, 2025 · There are two interfaces for implementing Map in Java. They are Map and SortedMap, and three classes: HashMap, TreeMap, and LinkedHashMap. This method is used in Java Map Interface to clear and remove all of the elements or mappings from a …

  6. Java: How to Get Keys and Values from a Map - Stack Abuse

    Nov 24, 2020 · In this article, we've gone over a few ways to get keys and values (entries) of a Map in Java. We've covered using an iterator and going through each Map.Entry<K, V>, as well as using a forEach() method both on the map itself, as well as its entry set.

  7. HashMap (Java Platform SE 8 ) - Oracle

    Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).

  8. A Guide to Java HashMap - Baeldung

    Jan 16, 2025 · A map is a key-value mapping, which means that every key is mapped to exactly one value and that we can use the key to retrieve the corresponding value from a map. One might ask why not simply add the value to a list.

  9. Java Map Collection: Complete Cheat Sheet with Code Example

    Java Map Collection Why Use Map? If you want to represent a group of objects as key-value pairs, then you should go with Map<K, V>. Each key is unique, and it maps to a specific value, making it an efficient structure for lookups, inserts, and updates. Map Interface Hierarchy 1. Map Interface (I) The top-level interface for all map-related classes.

  10. Iterate Over a Map in Java - Baeldung

    Dec 16, 2024 · A Map in Java is a data structure that stores key-value pairs, allowing for efficient lookups, updates, and deletions by key. Understanding how to iterate through a Map is crucial for some programming tasks.

  11. Some results have been removed
Refresh