Chapter 14: Java Collections, the Stack, the Heap, and the Garbage Collector

In this chapter, we will make a good start with the next project, an authentic-looking clone of the classic Snake game.

It is also time that we understood a little better what is going on underneath the Android hood. We constantly refer to "references," but what exactly is a reference and how does it affect how we build games?

We will cover the following topics in this chapter:

  • Managing memory with the stack, the heap, and the garbage collector
  • An introduction to the Snake game
  • Getting started with the Snake game project

Let's start with the theory part.

Managing and understanding memory

In Chapter 4, Structuring Code with Java Methods, we learned a bit about references. ...

Get Learning Java by Building Android Games - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.