Chapter 14. 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 the 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?

  • Managing memory with the Stack, the Heap, and the Garbage Collector
  • 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. Here is a quick recap

Note

… known as a reference type. They quite simply refer ...

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

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