Using methods 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, in action with the Exploring Method Overloading
app.
As we normally do, you can open the ready-typed code files in the usual way. The following two examples on methods can be found in the PACKT download in the chapter 8
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 an Empty Activity, and leave all the other settings at their default settings. 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 MainActivity
. Add them just...