The type inside the angle brackets is called a generic type parameter. It restricts the list to hold only that type:
ArrayList<Integer> scores = new ArrayList<>();
ArrayList<Double> prices = new ArrayList<>();
ArrayList<String> words = new ArrayList<>();
If you try to add a String to an ArrayList<Integer>, the compiler rejects it immediately. Without generics, you would only discover that mismatch at runtime when a ClassCastException crashes your program.
One restriction: you cannot use primitive types like int or double directly. You must use their wrapper class equivalents: Integer, Double, Boolean, and so on. I'll cover wrapper classes later in this section.