© Doug Winnie 2021
D. WinnieEssential Java for AP CompScihttps://doi.org/10.1007/978-1-4842-6183-5_26

26. Methods and Values

Doug Winnie1  
Mission Hills, KS, USA

Methods serve as engines that can process things for you and give you results that you can work with. Like any engine, you need to provide it something to work with.

Methods provide input and output capabilities. Input values are defined in the method definition, and output values are sent out using the return statement.

Accepting Values in Methods

A method can accept values to use within the method. To define a method to accept values, you need to state what type the values coming into it are and what variable name is used for the values in the method.
public static void average(float val1, ...

Get Essential Java for AP CompSci: From Programming to Computer Science 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.