O'Reilly logo

Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition by Rolf W. Rasmussen, Khalid A. Mughal

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

4.3. Defining Methods

The general syntax of a method declaration is

<method modifiers> <return type> <method name> (<formal parameter list>)         <throws clause> // Method prototype{ // Method body    <local variable declarations>    <nested local class declarations>    <statements>}

In addition to the name of the method, the method prototype can specify the following information:

  • scope or accessibility modifier (see Section 4.5, p. 121)

  • additional method modifiers (see Section 4.10, p. 144)

  • the type of the return value, or void if the method does not return any value (see Section 5.4, p. 176)

  • a formal parameter list

  • checked exceptions thrown by the method in a throws clause (see Section 5.9, p. 201)

The formal parameter list is a comma-separated ...

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