► |  | How to Design Classes Languages

1 | Professor J Beginner
2 | Professor J Intermediate
3 | Professor J Intermediate + Access
4 | Professor J Advanced
| Index

▼ | 4 | Professor J Advanced

4.1 | package
4.2 | import
4.3 | class
4.4 | interface
4.5 | Modifiers
4.6 | Field
4.7 | Method
4.8 | Constructor
4.9 | Statement
4.10 | Array Init
4.11 | Expression

Version: 4.1.4
top← prev up next →

#### 4.7`` Method

MethodReturn Id (Type Id ,...) {Statement ...}

Creates a method, bound to Id, that can be called on the current object, or instances of this class. The body of the method, the statements, will be evaluated sequentially when the method is called. The method name may not be the name of any classes defined in the same program or of any fields or methods in the same class. A method that does not return a value uses the void designation instead of a Type for MethodReturn.

abstract MethodReturn Id (Type Id ,...) ;

Creates a method, bount to Id, inside an abstract class. Like an interface signature, non-abstract classes that inherit this method must provide an implementation.

final MethodReturn Id (Type Id ,...) {Statement ...}

Creates a method, bound to Id, that cannot be overridden by future classes.

static MethodReturn Id (Type Id ,...) {Statement ...} Creates a method, bound to Id, that is tied to the class, not the instance of the class. This method cannot use the this expression within the Statement body.

Multiple methods can appear in a class body with the same name, provided that for each method with a given name the type of arguments or the number of arguments is unique.

top← prev up next →