Chapter 4: Structuring Code with Java Methods

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

In this chapter, we will cover the following topics:

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

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

Methods

Tip

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 ...

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.