8.4. Method Declarations

A method declares executable code that can be invoked, passing a fixed number of values as arguments.

MethodDeclaration:      MethodHeader MethodBodyMethodHeader:      MethodModifiersopt TypeParametersopt Result MethodDeclarator ThrowsoptMethodDeclarator:      Identifier ( FormalParameterListopt )

The FormalParameterList is described in §8.4.1, the MethodModifiers clause in §8.4.3, the TypeParameters clause in §8.4.4, the Result clause in §8.4.5, the Throws clause in §8.4.6, and the MethodBody in §8.4.7.

The Identifier in a MethodDeclarator may be used in a name to refer to the method.

It is a compile-time error for the body of a class to declare as members two methods with override-equivalent signatures (§8.4.2).

The ...

Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.