Methods
In Chapter 6, we learned about arrays in Java. We learned that arrays are data structures that are fixed in size. They are stored in contiguous memory locations where each location is of the same type. We also saw how to declare, initialize, and process arrays. Both the traditional and enhanced for
loops are ideal for processing arrays.
In addition, we discussed multi-dimensional arrays, including how they are organized and how to process them. Lastly, as arrays are very common, we discussed the Arrays
class, which has several useful methods for processing arrays.
In this chapter, we will cover methods. Methods enable us to create a named block of code that can be executed from elsewhere in the code. Firstly, we will explain why methods are so commonplace. You will learn the difference between the method definition and the method invocation. We will explore what a method signature is and how method overloading enables methods to have the same name, without conflict. We...