INF1B: Week 5: Collections; Stack vs Heap

Week highlights

By the time you have completed this week, you should understand:

From Lecture 8:

  • What ArrayLists are and what advantages they have over Arrays
  • How to add things to an ArrayList
  • Some methods that apply to ArrayLists
  • What wrapper classes are and why they might be need in ArrayLists
  • What iterators are
  • What maps or associative arrays are
  • What HashMaps are

From Lecture 9:

  • What stacks and heaps are for
  • What sorts of things are stored in the stack, and what in the heap
  • Potential problems with recursion and stacks
  • What immutability is
  • What the null object is for
  • The difference between shallow and deep copies

Lecture 8: Collections

Lecture 8 ➡ Objects First: read Chapter 4 Grouping Objects.

Lecture 9: Stack vs Heap

Lecture 9 ➡ Read Stack Memory In Java: Beginner's Guide (With Code Examples) | Zero To Mastery and Java Heap Space vs Stack - Memory Allocation in Java | DigitalOcean.

Tutorial: Testing

Instructions and materials: 

Solutions: 

Lab exercises

This week's lab exercises cover multidimensional arrays, static vs instance methods, and file paths. There are three warmup exercises and three core exercises.

What should I be doing with the assignments?

Continue with Assignment 1.

License
Creative Commons - Attribution Share A Like