-
Notifications
You must be signed in to change notification settings - Fork 0
HashMap
Larrox edited this page Aug 29, 2025
·
2 revisions
The HashMapUtil is a utility class in LarroxUtilsAPI that makes it easier to create and work with Map objects in Java.
It provides quick methods for creating empty maps, maps with predefined entries, and even a builder-style approach for more complex usage.
Note
Don’t forget to import the HashMapUtil before using it!
import dev.larrox.HashMapUtil;- Create an empty map with a single method call.
- Create a map with multiple entries using varargs.
- Quickly create a map with a single key-value pair.
- Use a builder pattern for more advanced cases.
Map<String, Integer> empty = HashMapUtil.create();Map<String, String> map1 = HashMapUtil.of(
"Name", "Steve",
"World", "Overworld"
);Map<Integer, String> map2 = HashMapUtil.of(1, "One");Map<String, Integer> map3 = HashMapUtil.<String, Integer>builder()
.put("Apple", 5)
.put("Banana", 10)
.build();- Use
of()when you need a quick map with a few entries. - Use
builder()for more readable and scalable maps when adding multiple pairs. - Prefer
create()if you want an empty map to fill later.