Chapter 4. Structuring Code with Java Methods

As we are starting to get comfortable with Java programming, in this chapter, we will take a closer look at methods because although we know that you can call them to make them execute their code, there is more to them that haven't been discussed so far.

In this chapter, we will look at the following topics:

  • The structure of methods
  • Method overloading versus overriding
  • How methods affect our variables
  • Using our knowledge of methods to progress the Sub' Hunter game

First, let's go through a quick method recap.

Methods

Note

A fact about methods: Almost all our code will be inside a method!

Clearly, methods are important. While this book will typically focus on the practical- getting-things-done aspect of programming ...

Get Learning Java by Building Android Games - Second 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.