O'Reilly logo

Oracle Certified Associate, Java SE 7 Programmer Study Guide by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Methods

A method is a group of statements used to complete a specific task. A method has a return value, a name, a set of parameters, and a body. Parameters are passed to a method and are used to perform an action. If a value is to be returned from a method, the return statement is used. A method may have zero or more return statements. A method that returns void may use a return statement but the statement does not have an argument.

Defining methods

Methods are defined as part of the class definition and normally follow the declaration of the instance variables. The method declaration specifies a return type. The return type void means that the method does not return a value.

Note

The Java naming convention for methods specifies that the first word ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required