To create a HashMap, you specify the types for the key and the value inside angle brackets. Both must be reference types, not primitives:
import java.util.HashMap;
HashMap<String, Integer> ages = new HashMap<>();
HashMap<Integer, String> idToName = new HashMap<>();
The first type is the key type, the second is the value type. You cannot write HashMap<int, String> because int is a primitive. Use the wrapper class Integer instead.
The empty angle brackets on the right side (<>) are called the diamond operator. Java infers the types from the left side, so you do not need to repeat them.