# LinkedHashMap missing?

**URL:** <https://discourse.processing.org/t/linkedhashmap-missing/46542>\
**Category:** Beginners\
**Created:** [June 13, 2025, 9:21pm UTC](https://discourse.processing.org/t/linkedhashmap-missing/46542 "2025-06-13T21:21:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![esc746](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/esc746/32/4258_2.png) [@esc746](https://discourse.processing.org/u/esc746)\
**Post date:** [June 13, 2025, 9:21pm UTC](https://discourse.processing.org/t/linkedhashmap-missing/46542/1 "2025-06-13T21:21:36Z")

</div>

Perhaps this is another case of user error.

Even if I “import java.util” I am told by the IDE that “the class LinkedHashMap does not exist”.

Why?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 13, 2025, 9:54pm UTC](https://discourse.processing.org/t/linkedhashmap-missing/46542/2 "2025-06-13T21:54:25Z")

</div>

When I try that on my system (macos) I get this:  
`Only a type can be imported. java.util resolves to a package`

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 14, 2025, 12:59am UTC](https://discourse.processing.org/t/linkedhashmap-missing/46542/3 "2025-06-14T00:59:08Z")

</div>

Just `import java.util;` is incomplete b/c it’s only the `package` part.

In order to actually import `class` [LinkedHashMap](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/LinkedHashMap.html), we have to include it after the `package` path:  
`import java.util.LinkedHashMap;`

Alternatively, though not a good practice, we can import the whole [“java.util”](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/package-summary.html) `package` via `*`:  
`import java.util.*;`

For more type flexibility, it’s advisable to declare a variable w/ the corresponding `interface` type instead; for this case a [Map](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Map.html):

```auto
import java.util.Map;
import java.util.LinkedHashMap;

public final Map<String, String> dict = new LinkedHashMap<>();

```

By doing so, your [LinkedHashMap](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/LinkedHashMap.html) can be more easily passed around to other functions as if it were any other [Map](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Map.html); but still keeping its features.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 14, 2025, 1:03am UTC](https://discourse.processing.org/t/linkedhashmap-missing/46542/4 "2025-06-14T01:03:40Z")

</div>

BtW, if your [Map](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Map.html)’s generics are `<String, String>`, `<String, Int>` or `<String, Float>`, Processing already got us covered w/ simpler alternative container classes w/ even more useful features like sorting:

> **[StringDict / Reference](https://processing.org/reference/stringdict)**
>
> A simple class to use a String as a lookup for a String value. String "keys" are associated with String values.

> **[IntDict / Reference](https://processing.org/reference/intdict)**
>
> A simple class to use a String as a lookup for an int value. String "keys" are associated with integer values.

> **[FloatDict / Reference](https://processing.org/reference/floatdict)**
>
> A simple class to use a String as a lookup for a float value. String "keys" are associated with floating-point values.

---

<div class="post-metadata">

**Author:** ![esc746](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/esc746/32/4258_2.png) [@esc746](https://discourse.processing.org/u/esc746)\
**Post date:** [June 14, 2025, 11:06am UTC](https://discourse.processing.org/t/linkedhashmap-missing/46542/5 "2025-06-14T11:06:20Z")

</div>

Thanks for a good answer! I had actually tried both of these (individually) with the same error:

```auto
import java.util.*;
import java.util.LinkedHashMap;

```

I had also tried restarted Processing but had not rebooted my system until today. And… now it works!

Addendum:  
Turned out that what I wanted was best served by a custom class, since I needed key-value pairs but also an identifier that I could use to group them. In many ways, a class is simpler than remembering all the different nomenclature for maps and composites.
