Chapter 16: Collections and Enumerations

This chapter will be part practical and part theory. First, we will code and use the Apple class and get our apple spawning ready for dinner. Afterward, we will spend a little time getting to know two new Java concepts, the ArrayList class and enumerations (enum for short). These two new topics will give us the extra knowledge we will need to finish the Snake game (mainly in the Snake class) in the next chapter. In this chapter, we will cover the following topics:

  • Adding graphics to the project
  • Coding and using the Apple class
  • Java Collections and the ArrayList class
  • The enhanced for loop

Let's go ahead with the project.

Adding the graphics

Grab the project's graphics on the GitHub repo; they are in ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.