{"id":133595,"date":"2026-11-26T09:43:16","date_gmt":"2026-11-26T15:43:16","guid":{"rendered":"https:\/\/www.albert.io\/blog\/?p=133595"},"modified":"2026-11-26T09:43:16","modified_gmt":"2026-11-26T15:43:16","slug":"ap-computer-science-a-unit-4-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/","title":{"rendered":"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections"},"content":{"rendered":"<p>The AP CSA Unit 4 cheat sheet covers Data Collections: arrays, ArrayList, 2D arrays, text files, searching, sorting and recursion. This is the largest unit on the exam at 30\u201340% of the multiple-choice score, and it drives two of the four free-response questions. Download it in two versions: Simple for a first pass, Ultimate for the dense final review.<\/p>\n\n    <div class=\"cs-tab-bar\" data-cs-config=\"{&quot;postId&quot;:133548,&quot;ajaxUrl&quot;:&quot;https:\\\/\\\/www.albert.io\\\/blog\\\/wp-admin\\\/admin-ajax.php&quot;,&quot;slots&quot;:{&quot;simple&quot;:{&quot;tier&quot;:&quot;simple&quot;,&quot;lang&quot;:&quot;&quot;},&quot;ultimate&quot;:{&quot;tier&quot;:&quot;ultimate&quot;,&quot;lang&quot;:&quot;&quot;}},&quot;lang&quot;:&quot;&quot;,&quot;tier&quot;:&quot;simple&quot;}\">\n                <div class=\"cs-tabs\" role=\"tablist\">\n                            <button class=\"cs-tab cs-tab--active\"\n                        role=\"tab\"\n                        aria-selected=\"true\"\n                        data-tier=\"simple\">\n                    Simple                <\/button>\n                            <button class=\"cs-tab\"\n                        role=\"tab\"\n                        aria-selected=\"false\"\n                        data-tier=\"ultimate\">\n                    Ultimate                <\/button>\n                    <\/div>\n        <div class=\"cs-preview-area\">\n                            <div class=\"cs-preview cs-preview--active\"\n                     data-slot=\"simple\">\n                                            <img decoding=\"async\" class=\"cs-preview-img\"\n                             src=\"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Simple-Cheat-Sheet-Preview-1.png\"\n                             alt=\"Simple cheat sheet preview\"\n                             loading=\"lazy\">\n                                    <\/div>\n                            <div class=\"cs-preview\"\n                     data-slot=\"ultimate\">\n                                            <img decoding=\"async\" class=\"cs-preview-img\"\n                             src=\"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png\"\n                             alt=\"Ultimate cheat sheet preview\"\n                             loading=\"lazy\">\n                                    <\/div>\n                    <\/div>\n        <div class=\"cs-download-area\">\n                            <div class=\"cs-download-panel cs-download-panel--active\"\n                     data-slot=\"simple\"\n                     role=\"tabpanel\">\n                    <a class=\"cs-download-btn\" href=\"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Simple-Cheat-Sheet-1.pdf\" data-slot=\"simple\" download>\n                        <svg class=\"cs-download-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n                            <path d=\"M8 1v10m0 0L4.5 7.5M8 11l3.5-3.5M2 13h12\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/>\n                        <\/svg>\n                        Download\n                    <\/a>\n                                            <a class=\"cs-customize-link\" href=\"https:\/\/www.albert.io\/blog\/?cheat_sheet_editor=1&#038;cs_id=133548&#038;cs_tier=simple\" data-slot=\"simple\" target=\"_blank\" rel=\"noopener\">\n                            Customize &rarr;\n                        <\/a>\n                                    <\/div>\n                            <div class=\"cs-download-panel\"\n                     data-slot=\"ultimate\"\n                     role=\"tabpanel\">\n                    <a class=\"cs-download-btn\" href=\"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-1.pdf\" data-slot=\"ultimate\" download>\n                        <svg class=\"cs-download-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\">\n                            <path d=\"M8 1v10m0 0L4.5 7.5M8 11l3.5-3.5M2 13h12\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/>\n                        <\/svg>\n                        Download\n                    <\/a>\n                                            <a class=\"cs-customize-link\" href=\"https:\/\/www.albert.io\/blog\/?cheat_sheet_editor=1&#038;cs_id=133548&#038;cs_tier=ultimate\" data-slot=\"ultimate\" target=\"_blank\" rel=\"noopener\">\n                            Customize &rarr;\n                        <\/a>\n                                    <\/div>\n                    <\/div>\n    <\/div>\n    <p class=\"cs-cta-strip\"><a href=\"https:\/\/www.albert.io\/ap-computer-science-a\">Practice AP\u00ae Computer Science A Unit 4 questions on Albert <span aria-hidden=\"true\">&rarr;<\/span><\/a><\/p>\n\n\n<h2>What&#8217;s on the AP\u00ae Computer Science A Unit 4 Cheat Sheet?<\/h2>\n<p>Both versions of the AP CSA Unit 4 cheat sheet cover all 17 topics in Unit 4 of the AP\u00ae Computer Science A Course and Exam Description, grouped into eight cards: data ethics and array basics, array algorithms, text files and wrapper classes, ArrayList methods, ArrayList algorithms, 2D arrays, searching and sorting, and recursion.<\/p>\n<p><strong>The Simple version<\/strong> is for students meeting this material for the first time or rebuilding shaky foundations. It keeps the core syntax, the standard loop patterns and the single most common trap for each topic, and it adds a few words of context the first time a term appears (an ArrayList is a &#8220;resizable list,&#8221; a 2D array is a &#8220;grid of rows and columns&#8221;).<\/p>\n<p><strong>The Ultimate version<\/strong> is for the last weeks before the exam. It adds the edge cases that multiple-choice questions are built on: what <em>set<\/em> and <em>remove<\/em> return, why <em>list.remove(2)<\/em> on an ArrayList of Integers removes an index rather than a value, how to trace selection and insertion sort pass by pass, how many times a nested loop body runs, and how many calls a two-branch recursive method makes.<\/p>\n<p>Neither version repeats the Java Quick Reference you get on exam day. Instead, they show how to use those methods correctly under time pressure.<\/p>\n<h2>AP CSA Unit 4 at a Glance<\/h2>\n<p>Unit 4 is weighted at 30\u201340% of the multiple-choice section, more than any other unit. Its topics:<\/p>\n<table>\n<tr><th>Topic<\/th><th>Name<\/th><th>Focus<\/th><\/tr>\n<tr><td>4.1<\/td><td>Ethical and Social Issues Around Data Collection<\/td><td>Privacy, security and bias in collected data<\/td><\/tr>\n<tr><td>4.2<\/td><td>Introduction to Using Data Sets<\/td><td>Finding patterns and the limits of a data set<\/td><\/tr>\n<tr><td>4.3<\/td><td>Array Creation and Access<\/td><td>Declaring arrays, default values, indexes<\/td><\/tr>\n<tr><td>4.4<\/td><td>Array Traversals<\/td><td>Indexed and enhanced for loops<\/td><\/tr>\n<tr><td>4.5<\/td><td>Implementing Array Algorithms<\/td><td>Sum, min\/max, count, shift, reverse<\/td><\/tr>\n<tr><td>4.6<\/td><td>Using Text Files<\/td><td>File, Scanner, IOException, split<\/td><\/tr>\n<tr><td>4.7<\/td><td>Wrapper Classes<\/td><td>Integer, Double, autoboxing and unboxing<\/td><\/tr>\n<tr><td>4.8<\/td><td>ArrayList Methods<\/td><td>add, get, set, remove, size<\/td><\/tr>\n<tr><td>4.9<\/td><td>ArrayList Traversals<\/td><td>Looping safely while the list changes<\/td><\/tr>\n<tr><td>4.10<\/td><td>Implementing ArrayList Algorithms<\/td><td>Filtering, removing and inserting in order<\/td><\/tr>\n<tr><td>4.11<\/td><td>2D Array Creation and Access<\/td><td>Rows, columns and g[row][col]<\/td><\/tr>\n<tr><td>4.12<\/td><td>2D Array Traversals<\/td><td>Row-major and column-major nested loops<\/td><\/tr>\n<tr><td>4.13<\/td><td>Implementing 2D Array Algorithms<\/td><td>Row sums, column sums, neighbors<\/td><\/tr>\n<tr><td>4.14<\/td><td>Searching Algorithms<\/td><td>Linear and binary search<\/td><\/tr>\n<tr><td>4.15<\/td><td>Sorting Algorithms<\/td><td>Selection and insertion sort<\/td><\/tr>\n<tr><td>4.16<\/td><td>Recursion<\/td><td>Base cases and tracing recursive calls<\/td><\/tr>\n<tr><td>4.17<\/td><td>Recursive Searching and Sorting<\/td><td>Recursive binary search and merge sort<\/td><\/tr>\n<\/table>\n<h2>Key Concepts in Unit 4: Data Collections<\/h2>\n<h3>Arrays: Creation, Access and Traversal (4.1\u20134.5)<\/h3>\n<p>An array holds a fixed number of values of one type. <em>new int[5]<\/em> creates five slots, each set to 0; a double array starts at 0.0, a boolean array at false, and an array of any object type, including String, starts full of <em>null<\/em>. That last point matters: <em>new Student[3]<\/em> creates three empty references, not three students, and calling a method on one of them throws a NullPointerException.<\/p>\n<p>Valid indexes run from 0 to <em>arr.length \u2212 1<\/em>. Note that <em>length<\/em> is a field on arrays, so it has no parentheses, while Strings use <em>length()<\/em> and ArrayLists use <em>size()<\/em>. Mixing these up is a quick way to lose a point on a free-response question.<\/p>\n<p><strong>Worked example.<\/strong> Find the largest value in <em>{\u22124, \u22129, \u22122, \u22127}<\/em>. If you start <em>max<\/em> at 0, no element is ever larger, and the method returns 0, a value that is not even in the array. Start <em>max<\/em> at <em>arr[0]<\/em> (\u22124) instead, compare from index 1 on, and the loop correctly ends with \u22122.<\/p>\n<p>The enhanced for loop (<em>for (int x : arr)<\/em>) gives you a copy of each value, so assigning to <em>x<\/em> never changes the array. Use an indexed loop whenever you need to write to the array, compare neighbors, or know where something is.<\/p>\n<p><strong>Exam tip:<\/strong> when a question asks whether every element meets a condition, return false the moment one fails and return true only after the loop finishes. Returning true inside the loop checks only the first element.<\/p>\n<h3>Text Files and Wrapper Classes (4.6\u20134.7)<\/h3>\n<p>Reading data from a text file is new to the course. You connect a file with <em>Scanner in = new Scanner(new File(&#8220;data.txt&#8221;));<\/em>, add <em>throws IOException<\/em> to the method header, then read in a <em>while (in.hasNext())<\/em> loop and close the Scanner at the end. The constructors and methods you need (<em>hasNext<\/em>, <em>next<\/em>, <em>nextInt<\/em>, <em>nextLine<\/em>, <em>close<\/em>) are on the Java Quick Reference.<\/p>\n<p><strong>Worked example.<\/strong> Each line of a file looks like <em>Ana,17<\/em>. Read the line with <em>nextLine()<\/em>, call <em>split(&#8220;,&#8221;)<\/em> to get the array <em>{&#8220;Ana&#8221;, &#8220;17&#8221;}<\/em>, then convert the second part with <em>Integer.parseInt(parts[1])<\/em>. Because you don&#8217;t know how many lines the file has, add each result to an ArrayList rather than a fixed-size array.<\/p>\n<p>ArrayLists hold objects only, which is why the wrapper classes Integer and Double exist. Java converts between <em>int<\/em> and <em>Integer<\/em> automatically (autoboxing and unboxing), so <em>list.add(5)<\/em> and <em>int x = list.get(0) + 1<\/em> both work.<\/p>\n<p><strong>Exam tip:<\/strong> unboxing a <em>null<\/em> Integer throws a NullPointerException, and <em>==<\/em> on two Integer objects compares references, not values. Use <em>.equals()<\/em> or unbox first.<\/p>\n<h3>ArrayList Methods and Algorithms (4.8\u20134.10)<\/h3>\n<p>An ArrayList grows and shrinks as you add and remove. <em>add(obj)<\/em> appends, <em>add(i, obj)<\/em> inserts and shifts later elements right, <em>set(i, obj)<\/em> replaces and returns the old value, and <em>remove(i)<\/em> deletes, shifts later elements left and returns what it removed. Every shift changes the index of every later element, which is what most ArrayList multiple-choice questions test.<\/p>\n<p><strong>Worked example.<\/strong> Remove every &#8220;x&#8221; from <em>[&#8220;a&#8221;, &#8220;x&#8221;, &#8220;x&#8221;, &#8220;b&#8221;]<\/em> with a forward loop that calls <em>remove(i)<\/em> on a match. At i = 1 the first &#8220;x&#8221; is removed and the second &#8220;x&#8221; slides into index 1. The loop then moves to i = 2, which is &#8220;b&#8221;, so one &#8220;x&#8221; survives. Looping backward from <em>size() \u2212 1<\/em> fixes it, because the shift only moves elements you&#8217;ve already checked.<\/p>\n<p>You can&#8217;t add or remove inside an enhanced for loop over an ArrayList: Java throws a ConcurrentModificationException. Use an indexed loop, or build a new list and add only the elements you want to keep.<\/p>\n<p><strong>Exam tip:<\/strong> on an <em>ArrayList&lt;Integer&gt;<\/em>, <em>list.remove(2)<\/em> removes the element at index 2, not the value 2. Expect at least one question built around that.<\/p>\n<h3>2D Arrays (4.11\u20134.13)<\/h3>\n<p>A 2D array is an array of rows. <em>new int[3][4]<\/em> makes 3 rows and 4 columns; <em>g.length<\/em> is the number of rows, <em>g[0].length<\/em> is the number of columns, and an element is always <em>g[row][col]<\/em>. Each row, <em>g[r]<\/em>, is itself a 1D array, so you can pass it to any method that takes one.<\/p>\n<p>Row-major order puts the row loop outside and the column loop inside; column-major swaps the loops. In both, the body still reads <em>g[r][c]<\/em>.<\/p>\n<p><strong>Worked example.<\/strong> To total each column of a 2 \u00d7 3 grid, the outer loop runs over columns (<em>c &lt; g[0].length<\/em>), you reset the sum to 0 inside it, and the inner loop runs over rows (<em>r &lt; g.length<\/em>) adding <em>g[r][c]<\/em>. Swap <em>g.length<\/em> and <em>g[0].length<\/em> and the code still works on a square grid but crashes on this one, which is why you should always test your loops on a grid that isn&#8217;t square.<\/p>\n<p><strong>Exam tip:<\/strong> when checking a neighbor such as <em>g[r \u2212 1][c]<\/em>, test the bound first (<em>r &gt; 0 &amp;&amp; \u2026<\/em>) so short-circuit evaluation stops the out-of-bounds access.<\/p>\n<h3>Searching, Sorting and Recursion (4.14\u20134.17)<\/h3>\n<p>Linear search checks every element and works on any data. Binary search checks the middle element and discards half of what&#8217;s left each step, so 1,000 sorted items take about 10 checks, but it only works on sorted data.<\/p>\n<p>Selection sort finds the smallest remaining value and swaps it to the front, so after k passes the first k elements are final. Insertion sort takes the next value and shifts larger values right until it fits, so after k passes the first k + 1 values are sorted among themselves but not necessarily final.<\/p>\n<p><strong>Worked example.<\/strong> Sort <em>{5, 2, 8, 1}<\/em>. Selection sort&#8217;s first pass swaps 5 and 1 to give <em>{1, 2, 8, 5}<\/em>. Insertion sort&#8217;s first pass moves 2 in front of 5 to give <em>{2, 5, 8, 1}<\/em>. Questions that ask for the array &#8220;after two passes&#8221; are testing whether you know this difference.<\/p>\n<p>A recursive method calls itself and needs a base case that stops it. For <em>fact(n)<\/em>, which returns 1 when <em>n &lt;= 1<\/em> and <em>n * fact(n \u2212 1)<\/em> otherwise, <em>fact(4)<\/em> calls down to <em>fact(1)<\/em>, then the returns unwind: 1, 2, 6, 24. Merge sort and recursive binary search use the same idea on halves of an array.<\/p>\n<p><strong>Exam tip:<\/strong> trace recursion with a call stack, one line per call on the way down, then fill in return values on the way back up.<\/p>\n<h2>How Unit 4 Shows Up on the Exam<\/h2>\n<p>The exam has 42 multiple-choice questions in 90 minutes (55% of the score) and four free-response questions in 90 minutes (45%), all taken in Bluebook. Unit 4 makes up 30\u201340% of the multiple-choice section, so expect roughly 13 to 17 questions on it. Most are tracing questions: what an array holds after a loop, what an ArrayList looks like after a series of <em>add<\/em> and <em>remove<\/em> calls, how many times a statement runs, what a recursive call returns, or what an array looks like after a given number of sorting passes.<\/p>\n<p>Two of the four free-response questions come straight from this unit. Question 3, Data Analysis with ArrayList, gives you a class that stores an ArrayList of objects and asks you to traverse it, call getters, and compute, filter or modify the data. Question 4, 2D Array, asks you to traverse and process a grid. Scorers reward correct loop bounds, accessing elements with the right syntax (<em>get(i)<\/em> versus <em>[i]<\/em>), calling the provided methods instead of reaching into private fields, and returning the right value on every path. The scoring guidelines forgive most minor syntax slips, such as a missing semicolon, but logic errors like skipping elements or going out of bounds cost points.<\/p>\n<p>The College Board&#8217;s <a href=\"https:\/\/apcentral.collegeboard.org\/courses\/ap-computer-science-a\">AP Computer Science A course page<\/a> has the full Course and Exam Description and past free-response questions, and the <a href=\"https:\/\/apcentral.collegeboard.org\/media\/pdf\/ap-computer-science-a-java-quick-reference.pdf\">Java Quick Reference<\/a> lists every library method you can use.<\/p>\n<h2>Common Mistakes in Unit 4<\/h2>\n<ol>\n<li><strong>Using <em>&lt;=<\/em> in the loop bound.<\/strong> <em>i &lt;= arr.length<\/em> reads one slot past the end. Fix: always <em>i &lt; arr.length<\/em> or <em>i &lt; list.size()<\/em>.<\/li>\n<li><strong>Removing from an ArrayList in a forward loop.<\/strong> The next element slides into the current index and gets skipped. Fix: loop backward, or only increment i when nothing was removed.<\/li>\n<li><strong>Starting a max or min at 0.<\/strong> It fails when every value is negative (or, for min, positive). Fix: start at the first element, or at <em>Integer.MIN_VALUE<\/em> \/ <em>Integer.MAX_VALUE<\/em>.<\/li>\n<li><strong>Swapping rows and columns.<\/strong> Using <em>g.length<\/em> as the column count breaks every non-square grid. Fix: rows are <em>g.length<\/em>, columns are <em>g[0].length<\/em>, and the element is <em>g[row][col]<\/em>.<\/li>\n<li><strong>Integer division in an average.<\/strong> <em>total \/ count<\/em> with two ints drops the decimal. Fix: cast first, <em>(double) total \/ count<\/em>.<\/li>\n<\/ol>\n<h2>Frequently Asked Questions<\/h2>\n<h3>Can I use this cheat sheet on the AP CSA exam?<\/h3>\n<p>No. The only reference allowed is the Java Quick Reference built into Bluebook. The AP CSA Unit 4 cheat sheet is a study tool: use it to review before practice sets and to check your work afterward.<\/p>\n<h3>Should I start with the Simple or Ultimate version?<\/h3>\n<p>Start with Simple if arrays, ArrayLists or recursion still feel new, or if you&#8217;re reviewing Unit 4 for the first time. Move to Ultimate once you can write a basic traversal without looking; its extra traps and traces are what separate a 4 from a 5.<\/p>\n<h3>Is reading text files really on the exam?<\/h3>\n<p>Yes. Topic 4.6 (Using Text Files) is part of the current course, and the File and Scanner classes are on the Java Quick Reference. Expect to read data with Scanner, split lines into parts, and store the results in an array or ArrayList.<\/p>\n<h3>Do I need to memorize merge sort?<\/h3>\n<p>You should understand how merge sort splits an array in half, sorts each half recursively and merges the results, and be able to trace it. Writing selection sort, insertion sort and binary search from memory is more useful practice for this unit&#8217;s multiple-choice questions.<\/p>\n<h3>How should I practice AP CSA Unit 4 review?<\/h3>\n<p>Trace code by hand. For every practice question, draw the array, ArrayList or grid, update it line by line, and only then pick an answer. Pair that with timed AP CSA Unit 4 practice on free-response Questions 3 and 4.<\/p>\n\n<section class=\"cs-footer\"><div class=\"cs-cta\"><h2 class=\"cs-cta-title\">Practice AP\u00ae Computer Science A Unit 4 on Albert<\/h2><p>A cheat sheet tells you what to know. Practice shows you whether you know it. Albert&#039;s AP\u00ae Computer Science A course has exam-style questions with a full explanation for every answer, organized by unit so you can drill exactly what this sheet covers.<\/p><a class=\"cs-cta-btn\" href=\"https:\/\/www.albert.io\/ap-computer-science-a\">Start practicing AP\u00ae Computer Science A<\/a><\/div><h2>More AP\u00ae Computer Science A cheat sheets<\/h2><nav class=\"cs-unit-nav\" aria-label=\"Previous and next AP\u00ae Computer Science A units\"><a class=\"cs-unit-prev\" rel=\"prev\" href=\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-3-cheat-sheet\/\"><span aria-hidden=\"true\">&larr;<\/span> Unit 3: Class Creation<\/a><span><\/span><\/nav><ul class=\"cs-units-list\"><li class=\"cs-units-full\"><a href=\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-cheat-sheets\/\">AP\u00ae Computer Science A full-exam cheat sheet<\/a><\/li><li><a href=\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-1-cheat-sheet\/\">Unit 1: Using Objects and Methods<\/a><\/li><li><a href=\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-2-cheat-sheet\/\">Unit 2: Selection and Iteration<\/a><\/li><li><a href=\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-3-cheat-sheet\/\">Unit 3: Class Creation<\/a><\/li><li aria-current=\"page\"><strong>Unit 4: Data Collections<\/strong><\/li><\/ul><p class=\"cs-calc\">See where you stand: plug your practice scores into the <a href=\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-score-calculator\/\">AP\u00ae Computer Science A score calculator<\/a> to estimate your exam score.<\/p><\/section>\n\n","protected":false},"excerpt":{"rendered":"<p>AP CSA Unit 4 cheat sheet for Data Collections: arrays, ArrayList, 2D arrays, text files, searching, sorting and recursion, in Simple and Ultimate versions.<\/p>\n","protected":false},"author":35,"featured_media":135913,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_lmt_disableupdate":"","_lmt_disable":"","albert_practice_url":"","albert_lit_section":"analysis","albert_lit_sort_order":0,"footnotes":""},"categories":[432,16193,5],"tags":[14030],"class_list":["post-133595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ap-computer-science-a","category-cheat-sheets","category-test-prep","tag-cheat-sheet"],"acf":{"post_id":null},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections | Albert Blog &amp; Resources<\/title>\n<meta name=\"description\" content=\"AP CSA Unit 4 cheat sheet for Data Collections: arrays, ArrayList, 2D arrays, text files, searching, sorting and recursion, in Simple and Ultimate versions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections | Albert Blog &amp; Resources\" \/>\n<meta property=\"og:description\" content=\"AP CSA Unit 4 cheat sheet for Data Collections: arrays, ArrayList, 2D arrays, text files, searching, sorting and recursion, in Simple and Ultimate versions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/\" \/>\n<meta property=\"og:site_name\" content=\"Albert Blog &amp; Resources\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-26T15:43:16+00:00\" \/>\n<meta name=\"author\" content=\"Chris D&#039;Angelo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chris D&#039;Angelo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/\"},\"author\":{\"name\":\"Chris D'Angelo\",\"@id\":\"https:\/\/www.albert.io\/blog\/#\/schema\/person\/67ba37eae3541638796f7aa6fc4150f5\"},\"headline\":\"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections\",\"datePublished\":\"2026-11-26T15:43:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/\"},\"wordCount\":2099,\"image\":{\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png\",\"keywords\":[\"Cheat Sheet\"],\"articleSection\":[\"AP\u00ae Computer Science A\",\"Cheat Sheets\",\"Test Prep\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/\",\"url\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/\",\"name\":\"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections | Albert Blog &amp; Resources\",\"isPartOf\":{\"@id\":\"https:\/\/www.albert.io\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png\",\"datePublished\":\"2026-11-26T15:43:16+00:00\",\"author\":{\"@id\":\"https:\/\/www.albert.io\/blog\/#\/schema\/person\/67ba37eae3541638796f7aa6fc4150f5\"},\"description\":\"AP CSA Unit 4 cheat sheet for Data Collections: arrays, ArrayList, 2D arrays, text files, searching, sorting and recursion, in Simple and Ultimate versions.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#primaryimage\",\"url\":\"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png\",\"contentUrl\":\"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png\",\"width\":1600,\"height\":1237},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.albert.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.albert.io\/blog\/#website\",\"url\":\"https:\/\/www.albert.io\/blog\/\",\"name\":\"Albert Blog &amp; Resources\",\"description\":\"Free resources and practice materials for students and teachers!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.albert.io\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.albert.io\/blog\/#\/schema\/person\/67ba37eae3541638796f7aa6fc4150f5\",\"name\":\"Chris D'Angelo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.albert.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fb9e4dedc4204f0e2a228983d8d89903089ef422ded88dfc4f634c10e17cfbdf?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fb9e4dedc4204f0e2a228983d8d89903089ef422ded88dfc4f634c10e17cfbdf?s=96&d=mm&r=g\",\"caption\":\"Chris D'Angelo\"},\"url\":\"https:\/\/www.albert.io\/blog\/author\/chrisd123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections | Albert Blog &amp; Resources","description":"AP CSA Unit 4 cheat sheet for Data Collections: arrays, ArrayList, 2D arrays, text files, searching, sorting and recursion, in Simple and Ultimate versions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/","og_locale":"en_US","og_type":"article","og_title":"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections | Albert Blog &amp; Resources","og_description":"AP CSA Unit 4 cheat sheet for Data Collections: arrays, ArrayList, 2D arrays, text files, searching, sorting and recursion, in Simple and Ultimate versions.","og_url":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/","og_site_name":"Albert Blog &amp; Resources","article_published_time":"2026-11-26T15:43:16+00:00","author":"Chris D'Angelo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Chris D'Angelo","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#article","isPartOf":{"@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/"},"author":{"name":"Chris D'Angelo","@id":"https:\/\/www.albert.io\/blog\/#\/schema\/person\/67ba37eae3541638796f7aa6fc4150f5"},"headline":"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections","datePublished":"2026-11-26T15:43:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/"},"wordCount":2099,"image":{"@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#primaryimage"},"thumbnailUrl":"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png","keywords":["Cheat Sheet"],"articleSection":["AP\u00ae Computer Science A","Cheat Sheets","Test Prep"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/","url":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/","name":"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections | Albert Blog &amp; Resources","isPartOf":{"@id":"https:\/\/www.albert.io\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#primaryimage"},"image":{"@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#primaryimage"},"thumbnailUrl":"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png","datePublished":"2026-11-26T15:43:16+00:00","author":{"@id":"https:\/\/www.albert.io\/blog\/#\/schema\/person\/67ba37eae3541638796f7aa6fc4150f5"},"description":"AP CSA Unit 4 cheat sheet for Data Collections: arrays, ArrayList, 2D arrays, text files, searching, sorting and recursion, in Simple and Ultimate versions.","breadcrumb":{"@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#primaryimage","url":"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png","contentUrl":"https:\/\/www.albert.io\/blog\/wp-content\/uploads\/2026\/11\/AP-Computer-Science-A-Unit-4-Ultimate-Cheat-Sheet-Preview-1.png","width":1600,"height":1237},{"@type":"BreadcrumbList","@id":"https:\/\/www.albert.io\/blog\/ap-computer-science-a-unit-4-cheat-sheet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.albert.io\/blog\/"},{"@type":"ListItem","position":2,"name":"AP\u00ae Computer Science A Unit 4 Cheat Sheet: Data Collections"}]},{"@type":"WebSite","@id":"https:\/\/www.albert.io\/blog\/#website","url":"https:\/\/www.albert.io\/blog\/","name":"Albert Blog &amp; Resources","description":"Free resources and practice materials for students and teachers!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.albert.io\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.albert.io\/blog\/#\/schema\/person\/67ba37eae3541638796f7aa6fc4150f5","name":"Chris D'Angelo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.albert.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fb9e4dedc4204f0e2a228983d8d89903089ef422ded88dfc4f634c10e17cfbdf?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fb9e4dedc4204f0e2a228983d8d89903089ef422ded88dfc4f634c10e17cfbdf?s=96&d=mm&r=g","caption":"Chris D'Angelo"},"url":"https:\/\/www.albert.io\/blog\/author\/chrisd123\/"}]}},"modified_by":null,"_links":{"self":[{"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/posts\/133595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/comments?post=133595"}],"version-history":[{"count":1,"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/posts\/133595\/revisions"}],"predecessor-version":[{"id":135415,"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/posts\/133595\/revisions\/135415"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/media\/135913"}],"wp:attachment":[{"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/media?parent=133595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/categories?post=133595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.albert.io\/blog\/wp-json\/wp\/v2\/tags?post=133595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}