BFOIT - Introduction to Computer Programming

Appendix A (Jargon)

-   M   -

A method is a Java procedure. Methods provide the actions in Java programs - they do things. They compute things. They modify fields. They output words, graphics, sounds, send messages over the Internet, an infinite number of different things...

All methods have a type, which means they either output a value of their declared type or, if the type is "void," no output is produced.

There are two parts to a method declaration:

  1. a header which introduces the method. A header has the form:
    modifiers type methodIdentifier ( parameters ) throws exception

    1. modifiers are keywords like public, private, abstract, and static.
    2. type is a keyword for a Java primitive type, the keyword void, or a reference-type.
    3. methodIdentifier is the name you are giving to the method being declared.
    4. ( parameters ) it the list of parameters that the method is expecting when it is invoked. Although the parenthesis MUST be there, parameter declarations are needed only when the method needs them.
    5. throws exception is an optional declaration necessary when the method could generate a checked exception.
  2. a body. The body of a method is either simply a semicolon, which means the body isn't implemented at this point, or it's a block.

Other jargon:  A   B   C   D   E   F  G H  I   J  K  L   M  N  O   P  Q  R   S   T  U  V   W  X Y Z

Back to HomePage

Public Domain Mark
This work (BFOIT: Introduction to Computer Programming, by Guy M. Haas),
identified by Berkeley Foundation for Opportunities in IT (BFOIT),
is free of known copyright restrictions.