3.3. Create methods with arguments and return values

[6.1] Create methods with arguments and return values; including overloaded methods

In this section, you’ll work with the definitions of methods, which may or may not accept input parameters and may or may not return any values.

A method is a group of statements identified with a name. Methods are used to define the behavior of an object. A method can perform different operations, as shown in figure 3.13.

Figure 3.13. Different types of methods

  1. The method setModel can access and modify the state of a Phone instance.
  2. The method printVal uses only the method parameter passed ...

Get OCA Java SE 8 Programmer I Certification Guide 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.