A generic type in AP Computer Science A is a class like ArrayList<E> whose angle-bracket type parameter E specifies the type of elements it holds, so methods like add() and get() accept and return that exact type and the compiler can catch type mismatches before the program runs.
A generic type is a Java class with a type parameter in angle brackets. On the AP exam, that means ArrayList<E>, where E is a placeholder you fill in when you create the list. Writing ArrayList<String> names = new ArrayList<String>(); tells Java that this list holds Strings and nothing else. From that point on, every ArrayList method is locked to that type. add() only accepts Strings, and get() hands back a String you can use immediately, no casting required.
The payoff is compile-time type safety. Per EK 4.8.A.3, ArrayList<E> is preferred over plain ArrayList because the compiler can find type errors that would otherwise only show up as crashes at run-time. Think of the angle brackets as a label on a storage bin. Without the label, you find out something wrong is in the bin only when you reach in and get surprised. With the label, Java refuses to let the wrong item in at all.
Generic types live in Topic 4.8 (ArrayList Methods) in Unit 4: Data Collections, supporting learning objective AP Comp Sci A 4.8.A, which asks you to develop code using ArrayList objects and determine the result of calling their methods. You can't do either of those without reading the generic type. The <E> tells you what get() returns, what add() accepts, and whether a code segment even compiles. Since Unit 4 carries heavy weight on both the multiple-choice section and the array/ArrayList FRQ, the ArrayList<Type> declaration is something you'll write or interpret on nearly every collections question.
Keep studying AP® Computer Science A Unit 4
.get() method (Unit 4)
The generic type is what makes get() useful. If the list is declared ArrayList
Object reference (Unit 4)
Per EK 4.8.A.1, an ArrayList stores object references, not the objects themselves. The generic type tells you what kind of object those references point to. This is also why you can't write ArrayList
ArrayList constructor (Unit 4)
EK 4.8.A.2's constructor pairs with the generic type in one line. The declaration ArrayList
Generic types show up the moment any question instantiates an ArrayList. A common multiple-choice setup gives you a code segment with /* missing code */ and asks which declaration correctly creates the list, for example picking ArrayList<String> list = new ArrayList<String>(); over options with wrong syntax or mismatched types. You also need to trace what get() returns based on the declared type parameter. On the free-response section, the array/ArrayList question expects you to declare lists with the correct generic type yourself. Writing a raw ArrayList instead of ArrayList<E> is exactly the kind of thing the CED says to avoid, so always include the angle brackets.
A raw ArrayList compiles, but it treats every element as a plain Object, so type mistakes only blow up at run-time. ArrayList
A generic type uses angle brackets, like ArrayList
When you declare ArrayList
ArrayList
The type parameter must be a class, not a primitive, because an ArrayList stores object references (so use Integer, not int).
The standard exam-ready declaration is ArrayList
It's a class with a type parameter in angle brackets, like ArrayList
No. ArrayLists store object references, and int is a primitive, not an object. Use the Integer wrapper class instead, as in ArrayList
It compiles, but the CED (EK 4.8.A.3) says ArrayList
ArrayList
The generic type sets get()'s return type. With ArrayList
Connect this key term to the AP exam workflow: review the course, practice questions, and check related study tools.
Review units, study guides, and course resources.
Check this vocabulary in multiple-choice context.
Apply key concepts in written AP responses.
Estimate the exam score you are working toward.
Review the highest-yield facts before practice.
Put the full course together before test day.