APCS Unit 7: ArrayLists

Dynamic data storage as a new tool

ARRAYLISTS OVERVIEW

An array is a unit of information in Java that can store multiple values.  We spent time last semester getting used to to arrays, traversing arrays, and working with these static data storage tools.  In this unit we get to add to our list of tools by studying the ArrayList.  ArrayLists are like arrays in many ways, but we will have a lot more control over how they work and how we use them.  In this unit, we’ll go through three major steps:

  1. Learn the basics of ArrayLists to start getting a handle on how to create and work with ArrayLists for simple tasks
  2. Compare Arrays and ArrayLists in order to understand when each should be used and the main differences between their application
  3. Use ArrayLists in more example programs just to get a good handle on how ArrayLists function!

When you’re done, you’ll have a new tool for storing information in your programs!

PART 1: ARRAYLIST BASICS

(20 pts)  About 3 days

We start this unit be reviewing the basics of how to create (instantiate) an ArrayList as well as how to work with ArrayLists.  Here the focus will be the ArrayList constructor, as well as the methods add(), remove(), size(), and get().  Keep thinking about how ArrayLists are different from arrays! 

PART 2: ARRAYS vs ARRAYLISTS

(30 pts)  About 3 days

Next up we’ll focus in more detail on the differences between arrays (from Unit 5) and ArrayLists.  You’ll create various programs using arrays and then recreate them with arrayLists to consider the differences.  We’ll also look at when each of those tools is the right tool for the job!

PART 3: ARRAYLISTS IN ACTION

(30 pts)  About 2 days

Finally, we’ll return to some java challenges with ArrayLists just to get some more good practice.  Later in the semester we’ll look to make some more complex programs using ArrayLists.  For now, we’ll focus on getting a handle on the different tools we have at our disposal.

PART 1: ArrayList Basics

The basics of ArrayList creation and interaction

ArrayList Creation Examples
<Watch for the use of the angle brackets>

ArrayLists are similar to arrays in that they act like lists that can store a variety of information.  If we’re tricky about it, an ArrayList can even store information of different types (but we’ll deal with that next unit). Here, we look to ArrayLists as a more useful type of list because an ArrayList can actually change size, while an array is stuck being the size it was when it was created.

This means that if we are storing data in an ArrayList, then we are allowed to add elements (so the ArrayList gets longer), or remove elements (so that the ArrayList gets shorter).  This flexibility will be tremendously helpful in situations where things are changing.

GRADING & PROCESS

 Watch the three presentations on ArrayLists and take careful notes in your engineering notebook.  Your notes should include details about how to create (instantiate) ArrayLists, and how to use the add(), remove(), get(), and size() methods!

 Complete 8 Java Tasks about ArrayLists and traversing ArrayLists.

  Have Benshoof confirm your working programs! 

ArrayLists Intro

ArrayLists in Classes

ArrayLists vs Arrays 1

What’s Due In ArrayLists Part 1: ArrayList Basics

  • Array Notes
  • 8 Array Java Tasks
  • Benshoof’s Check-Off

Here’s what’s due in Part 1: ArrayList Basics

  1.  Take a page of notes on the creation and use of ArrayLists, including how to traverse a ArrayLists
  2. Complete all 8 ArrayList Tasks in Java
  3.  Have Benshoof check-off your working programs

PART 2: Arrays vs ArrayLists

Comparing & Contrasting Two Essential Java Tools

Now that we’ve had some time to play with ArrayLists in some simple cases, it’s useful to take some time and compare the use of ArrayLists to the uses of arrays.  In this part of the unit you’ll make 4 different programs twice (for a total of 8 programs).  For each program, you’ll make it function properly using arrays (like we did back in Unit 5).  Then you’ll recreate the same type of program – with exactly the same functionality – with ArrayLists.  The goal is to emphasize and think about the differences between these two tools.  Take good notes 

GRADING & PROCESS

 Take a full page of notes on 2-Dimensional arrays.  Make sure that your notes include details on instantiating, recalling, and traversing these types of arrays.

 Complete 8 Java Tasks about 2-Dimensional arrays and traversing arrays.

 Complete 8 more codingbat.com challenges in the String-2 group.

 

2D Array Overview
More About 2D Arrays
2D Arrays of Objects

What’s Due In ArrayLists Part 2: Arrays vs ArrayLists

  • Notes on 2D Arrays
  • 8 Array Tasks
  • 8 Codingbat Challenges
  • Benshoof’s Check-Off

Here’s what’s due in Part 2: Arrays vs ArrayLists

  1.  Take a full page of notes on multi-dimensional arrays
  2.  Complete 8 Java tasks about 2D Arrays
  3. Complete 8 Codingbat challenges in the String-2 group
  4.  Have Benshoof check-off your careful drawing

PART 3: Build It!

Put your plan into action and build your Bug Bot in our workshop
Soldering – how to!  Give some thoughts and notes that summarize the big ideas
Check out this video on how to solder
Check out this video on how to wire your bugbot
Check out this extra video on troubleshooting

What’s Due In Bug Bot Part 3: Build It!

  • Build It
  • (Extra Credit) Decorate it
  • Benshoof’s Check-Off
Here’s what’s due in Part 3: Build It!

  1.  Get into the makerspace and build your Bug Bot!  Make sure it functions properly!
  2.  If you have extra time, give your Bug Bot that special touch by painting, lasering, or making stickers to customize it!
  3.  Have Benshoof check-off your finished, working Bug Bot

Double Check: Unit Expectations

Check what you need to have completed by the unit deadline
The purpose of this unit is to use the Engineering Design Process to wire, design, and build a working Bug Bot.  You should have had the chance to do some soldering, design your own Bug Bot, and use the tools in our makerspace to build your Bug Bot.  If you were really on-task and working hard, you should have also had time to decorate your Bug Bot to make it look super cool.  By the unit deadline, you should have completed and be able to submit the following items:

Engineering Notebook:

 (Part 1) Definition of problem, criteria, constraints, and Bug Bot Overview notes

 (Part 1) Wiring diagram, soldering notes, and wiring reflection

 (Part 2) Bug Bot Design brainstorm, notes, and careful drawing

 (Part 3) Final drawing/picture, half-page written reflection on Bug Bots

Building & Making:

 (Part 1) Wiring should work, soldering should be clean and complete

 (Part 2) Bug Bot design should be carefully drawn out including labels and diagrams

 (Part 3) The Bug Bot should be assembled and should function properly

Benshoof Checkpoints

 (Part 1) Benshoof should have seen your working wiring before you moved on

 (Part 2) Benshoof should have seen your careful drawing before you moved on

 (Part 3) Benshoof should have seen your working Bug Bot