Basic HTML version of Foils prepared 19 July 97

Foil 16 Method Definitions

From Java Tutorial - Summer 1997 Part II: Java Language and Object-Oriented Concepts CEWES Tutorial -- July 22-25 1997. by Nancy J. McCracken,Geoffrey C. Fox

Method definition examples for Foil 16
Subprograms in Java are called methods. The definition format is
  • Returntype Methodname ( Parameterlist )
  • {
    • declarations and statements
  • }
The parameter list contains the types and names of all the parameters.
The declarations and statements are called the body of the method. Parameter names and variables declared in the body are local to it.
Control returns from the methods either when the body is finished execution or a return statement is encountered. Return statements may also return a result.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998