---
title: "Java: Hashmaps"
date: 2015-01-01
description: "## Quick summary * consists of key-value pairs * HashMaps, TreeMap, and LinkedList * class name: HashMap Eclipse example: hashmaps ## Example ```java HashMap map = new HashMap<Integer,..."
canonical_url: https://idratherbewriting.com/java-hashmaps/
---
# Java: Hashmaps
## Quick summary

 - consists of key-value pairs

 - HashMaps, TreeMap, and LinkedList

 - class name: HashMap<Integer, String>

Eclipse example: hashmaps

## Example

```java
HashMap map = new HashMap();
map.put(5, "five");
map.put(6, "six");
map.put(2, "two");
map.put(1, "one");
map.put(9, "nine");
```

## Map methods

Here’s how you add to the map:

```java
map.put(key, value);
e.g.,
map.put(5, "five")
```