Maps

suggest change

Versions

The original version list named Java SE 1.2 through 8, and 9 (Early Access).

Introduction

The java.util.Map interface represents a mapping between keys and their values. A map cannot contain duplicate keys; and each key can map to at most one value.

Since Map is an interface, you need to instantiate a concrete implementation of that interface in order to use it. There are several Map implementations, and the most used are java.util.HashMap and java.util.TreeMap.

Remarks

A map is an object which stores keys with an associated value for each key. A key and its value are sometimes called a key/value pair or an entry. Maps typically provide these features:

The most commonly used map implementation is HashMap. It works well with keys that are strings or numbers.

Plain maps such as HashMap are unordered. Iterating through key/value pairs may return individual entries in any order. If you need to iterate through map entries in a controlled fashion, you should look at the following:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents