CreateList in AP Computer Science A

In AP Computer Science A, createList is a method (from the 2024 FRQ's WordChecker class) that traverses an ArrayList<String>, selects the words that begin with a target string, removes that prefix from each, and returns the results in a new ArrayList.

Verified for the 2027 AP Computer Science A examLast updated June 2026

What is createList?

createList is a classic "original algorithm" in the AP CSA sense. It isn't a built-in Java method. It's a method you write that walks through an ArrayList of strings, checks each one against a condition (does it start with a given target string?), and for every match, chops off that prefix and adds what's left to a brand-new list. So if the list contains "unhappy", "under", and "happy" and the target is "un", createList returns a list containing "happy" and "der".

Think of it as two standard moves stitched together. First, a filtering traversal (keep only elements with a property). Second, a String transformation on each survivor (substring off the prefix). That combo is exactly what EK 4.10.A.2 is talking about when it says some ArrayList algorithms require String methods inside the loop. The big design point is that createList builds and returns a new ArrayList instead of mutating the original, which sidesteps the classic remove-while-traversing trap.

Why createList matters in AP® Computer Science A

createList lives in Topic 4.10 (Developing Algorithms Using ArrayLists) in Unit 4: Data Collections. It directly supports learning objective 4.10.A, which asks you to develop code for standard and original algorithms involving ArrayList objects and to determine what those algorithms produce. EK 4.10.A.1 lists the standard traversal patterns (count elements with a property, insert, delete, and so on), and createList is what happens when the exam remixes those patterns into something original. It also hits EK 4.10.A.2, since you need String methods working alongside the loop. If you can write createList cold, you've proven you can handle the ArrayList FRQ, which shows up on the free-response section essentially every year.

How createList connects across the course

Traversal (Unit 4)

createList is a traversal at its core. You visit every element exactly once with a for or enhanced for loop. The twist is that you're reading from one list and writing to another, so you never have to worry about skipping elements the way you do when you remove from a list mid-loop.

Standard ArrayList algorithms (Unit 4)

EK 4.10.A.1 lists patterns like "determine the number of elements having a particular property" and "insert elements." createList is those two patterns fused together. Once you see original algorithms as remixes of standard ones, FRQ prompts stop feeling brand new.

String methods (Unit 1)

The prefix check and prefix removal run on String tools like substring, length, and equals from way back in Unit 1. EK 4.10.A.2 makes this explicit. ArrayList algorithms often need String manipulation inside the loop, so Unit 1 skills never actually go away.

Duplicate elements (Unit 4)

Both createList and duplicate-detection are property-based traversals over a list. The difference is the question each loop answers. Duplicate checks compare elements to each other, while createList compares each element to an outside target string.

Is createList on the AP® Computer Science A exam?

createList comes straight from the 2024 FRQ Q3, which gave you a WordChecker class holding an ArrayList and asked you to write methods that analyze and manipulate the word list. On the free response, you're expected to write the full method body, which means declaring a new ArrayList, looping over the original, testing each string against the target prefix, using substring to strip the prefix, adding the result to the new list, and returning it. Common point-losers are off-by-one substring indices, calling remove on the list you're looping over, and forgetting to return the new list. In multiple choice, the same idea appears in reverse. You're shown a filter-and-transform loop and asked to determine the exact contents of the resulting list, which is the "determine the result" half of 4.10.A.

CreateList vs Removing elements from the original ArrayList

createList does not delete anything from the original list. It leaves the original untouched and builds a separate result list. The "delete elements" standard algorithm in EK 4.10.A.1 mutates the list in place, which forces you to manage shifting indices (the classic bug where removing at index i skips the next element). Filtering into a new list avoids that problem entirely, which is exactly why FRQ specs like createList ask you to return a new ArrayList.

Key things to remember about createList

  • createList is the method from the 2024 AP CSA FRQ Q3 (WordChecker) that returns a new ArrayList of strings that start with a target prefix, with that prefix removed from each.

  • It supports LO 4.10.A, which requires you to both write original ArrayList algorithms and predict their output.

  • The algorithm is a filtering traversal plus a String transformation, combining EK 4.10.A.1 patterns with the String methods called out in EK 4.10.A.2.

  • Build a new list instead of removing from the original, because removing while traversing causes index-shifting bugs that cost FRQ points.

  • When stripping a prefix of length n, the leftover text is str.substring(n), and getting that index right is where most substring mistakes happen.

  • Don't forget the bookends of the method, declaring the new ArrayList before the loop and returning it after.

Frequently asked questions about createList

What is the createList method in AP Computer Science A?

createList is a method from the 2024 AP CSA FRQ Q3 (the WordChecker class) that traverses an ArrayList, keeps the words that begin with a given target string, removes that prefix from each, and returns them in a new ArrayList. It's a textbook example of an original algorithm under LO 4.10.A.

Does createList change the original ArrayList?

No. createList leaves the original list completely intact and returns a brand-new ArrayList holding the transformed matches. That design choice is what lets you avoid the remove-while-traversing bug.

How is createList different from the delete-elements ArrayList algorithm?

The delete-elements algorithm from EK 4.10.A.1 mutates the list in place with remove, so you have to adjust your index after each removal. createList never calls remove. It copies transformed matches into a new list, so indices never shift and the original data survives.

Was createList on a real AP exam?

Yes. It appeared on the 2024 FRQ Q3, where the WordChecker class contained an ArrayList and methods for analyzing the word list. Even in other years, the FRQ section reliably includes an ArrayList traversal method in this same style.

What String methods do I need to write createList?

You mainly need substring to check the prefix and strip it, length to know how many characters to cut, and equals to compare strings (never == for String content). EK 4.10.A.2 explicitly flags that some ArrayList algorithms require String methods like these inside the traversal.