declare hashmap java

Java
//remember to first import java.util.*; first

//you can swap out string or integer for other data types
Map<String, Integer> d = new HashMap<>();
import java.util.HashMap; // import the HashMap class

HashMap<String, String> capitalCities = new HashMap<String, String>();

Source

Also in Java: