6.1 Introduction
Experience has shown that the best way to develop and maintain a large program is to construct it from small, simple pieces. This technique is called divide and conquer. Methods, which we introduced in Chapter 3, help you modularize programs. In this chapter, we study methods in more depth.
You’ll learn more about static methods, which can be called without the need for an object of the class to exist. You’ll also learn how Java is able to keep track of which method is currently executing, how local variables of methods are maintained in memory and how a method knows where to return after it completes execution.
We’ll take a brief diversion into simulation techniques with random-number generation and develop a version of the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access