D.1. Introduction

In this appendix, we study methods in more depth. You’ll see that it’s possible to call certain methods, called static methods, without the need for an object of the class to exist. You’ll learn how to declare a method with more than one parameter. You’ll also learn how Java keeps 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 casino dice game called craps that uses most of the programming techniques you’ve used to this point in the book. In addition, you’ll learn how to declare values that ...

Get Android™ How to Program, Second 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.