Using method demo apps
Here we will quickly build two apps to explore methods a bit further. First, we will explore the fundamentals with the Real World Methods
app, and then we will glimpse a new topic, method overloading, with the Exploring Method Overloading
app.
As usual, you can open the ready-typed code files in the usual way. The next two examples of methods can be found in the download bundle in the Chapter 9 folder and the Real World Methods
and Exploring Method Overloading
sub-folders.
Real-world methods
First, let's make ourselves some simple working methods complete with return type parameters and fully functioning bodies.
To get started, create a new Android project called Real World Methods
, use the Empty Activity template, and leave all the other settings at their default. Switch to the MainActivity.java
file by left-clicking the MainActivity.java tab above the editor and we can start coding.
First, add these three methods to the MainActivity
class...