O'Reilly logo

Learn to Program with Minecraft Plugins, 2nd Edition by Andy Hunt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use a Java HashMap

HashMap is a funny name. The “hash” part refers to how it works internally; it really has nothing to do with how you use it.

But the “map” part is about what you’d think: it maps a key, which can be anything, to a value, which can also be anything.

Other languages might call this a dictionary, an associative array or some kind of associative memory. They all mean the same thing. With an array, you use an integer as the index. With a HashMap, you can use any object as the key, especially Strings (see Figure 2, A HashMap).

images/HashMap.png
Figure 2. A HashMap

We’ll use this a lot in the plugins. It’s a great way to keep track of players, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required