APCS Unit 5
Arrays Introduction

 Download the Unit 5 Rubric

 Unit 5 Quiz Coming Soon!

Welcome to the 5th unit of AP Computer Science! We’ve covered a lot this semester – from Jeroos and basic Java programs, to control structures and object oriented design.  Next on the list though is a new tool for storing information that will make it much easier to store large groups of data in just a few variables. For this, we’ll use something called arrays. Arrays are data structures in programming that have the following characteristics:

  • They have a single name for the entire array (list)
  • They can reference each spot individually
  • They start counting their spots at ‘location 0’
  • They all have a non-negative length

As we practice with arrays and try to do various things with them, we’ll need to be able to do a few very specific tasks:

  1. Create arrays with the values we want
  2. Recall or change the values within an array
  3. Print an entire array using a ‘for’ loop
  4. Traverse an array to look at each spot

Once we’ve tackled these skills, we’ll be able to use arrays for all sorts of good things!

Part 1: One-Dimensional Arrays

Array Examples

Here in the first part of the unit, we need to get used to something called a 1-dimensional array.  The 1-dimensional arrays act like lists where you can have multiple (potentially a lot) of values stored within a single variable.  This array is great if you need to store a lot of grades for a single student, a lot of names for a single high school course, or a lot of prices for goods within a single store.  The uses for 1-dimensional arrays are many, and to get started we need to know how to make them, how to change them, and how to use the elements inside them!


 Take a page of notes on Arrays and the ideas presented in the videos below and in class

 Complete the 8 Java tasks about arrays

 Complete 8 challenges in the Java -> String 3 section on codingbat.com

 Have Mr. Benshoof check off your completed tasks

Traversing 1-Dimensional Arrays

Classes & Arrays

Part 2: Multi-Dimensional Arrays

Example Getters & Setters

The second part of this unit is about writing methods that can let a class interact with another calss's variables. Since we make the variables in a class PRIVATE, other classes are not able to reach in and see what they are without asking.  In order for them to ask what a variable equals - or to change the value of a variable - we need to make methods that can facilitate that interaction.  These methods are called “Setters” and “Getters”.

SETTERS are methods that let another class SET the value of a variable.  These have a return type of ‘void’ and are just used to set or reset an object’s instance variable.  This is like the phone company changing your phone number:  they need to SET your new phone number, so they do it.

GETTERS are methods that let another class GET the value of a variable.  These have a return type that matches they variable type of the thing being asked for.  It’s like someone asking you for your phone number: they want to GET your phone number, so you RETURN it to them.


 Take a page of notes on Object Oriented Design and the presentations below about setters and getters

 Complete the 8 Java tasks about setters & getters

 Complete 6 challenges in the Java -> String 1 section on codingbat.com

 Have Mr. Benshoof check off your completed tasks

Getters & Setters

More About Methods

Part 3: Tic-Tac-Toe

Example Class Structure

The final part of our unit has us combine the ideas of multiple classes within a single program to design the structure of a program to keep track of Lathrop's new zoo! Here you'll get the chance to practice the class building ideas we've covered in the first two parts of the unit.  As you develop your program, the real emphasis is supposed to be on the organization and structure of a larger program.  Because of this, you don't need to spend too much time trying to make things connect and print properly - instead, focus on the interaction between objects!  Have fun and be creative.


 Brainstorm ideas for the classes and structure of your LHS Zoo program

 Create your LHS Zoo Program

 Write APCS Log 4: Object Oriented Design

APCS Unit 5 Map
Looking for something?  Here you'll find a library of links to all the documents, images, and videos needed here in APCS Unit 5.