Basic HTML version of Foils prepared Sept 21 1998

Foil 13 Method Definitions

From Java Tutorial 98- 2: Java Language and Object Oriented Techniques NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

Method definition examples for Foil 13
Subprograms in Java are called methods. The definition format is
  • Modifiers 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 Sat Nov 28 1998