CLASSES
Method Declarations
8.4
class PaintedPoint extends ColoredPoint implements Paintable
{
. . .
RED
. . .
}
the fields
RED
,
GREEN
, and
BLUE
are inherited by the class
PaintedPoint
both
through its direct superclass
ColoredPoint
and through its direct superinterface
Paintable
. The simple names
RED
,
GREEN
, and
BLUE
may nevertheless be used
without ambiguity within the class
PaintedPoint
to refer to the fields declared in
interface
Colorable
.
8.4 Method Declarations
The diversity of physical arguments and opinions embraces all sorts of methods.
Michael de Montaigne (1533 1592),
Of Experience
A
method
declares executable code that can be invoked, passing a fixed number of
values as arguments.
MethodDeclaration:
MethodHeader MethodBody
MethodHeader:
MethodModifiers
opt
ResultType MethodDeclarator Throws
opt
ResultType:
Type
void
MethodDeclarator:
Identifer
(
FormalParameterList
opt
)
The
MethodModifiers
are described in 8.4.3, the
Throws
clause in 8.4.4, and the
MethodBody
in 8.4.5. A method declaration either specifies the type of value that
the method returns or uses the keyword
void
to indicate that the method does not
return a value.
The
Identifier
in a
MethodDeclarator
may be used in a name to refer to the
method. A class can declare a method with the same name as the class or a field of
the class.
For compatibility with older versions of Java, a declaration form for a method
that returns an array is allowed to place (some or all of) the empty bracket pairs
that form the declaration of the array type after the parameter list. This is sup
ported by the obsolescent production:
155
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved