Java Reference
In-Depth Information
3 . In general, to use a predefined method, you must:
a. Know the name of the class containing the method, and the name of
the package containing the class that contains the method.
b. Import the class into the program.
c. Know the name and type of the method, and the number and types of
the parameters (arguments).
4 . To use a method of a class contained in the package java.lang in a
program, you do not need to explicitly import these classes into your
program.
5 . To simplify the use of static methods (members) of a class, Java 5.0 and
higher versions provide the static import statement.
6 . The two types of user-defined methods are value-returning methods and
void methods.
7 . Variables defined in a method heading are called formal parameters.
8 . Expressions, variables, or constant values used in a method call are called
actual parameters.
9 . In a method call, the number of actual parameters and their types must
match the formal parameters in the order given.
10 . To call a method, use its name together with the actual parameter list.
11 . A value-returning method returns a value. Therefore, a value-returning
method is typically used (called) in either an expression or an output
statement, or as a parameter in a method call.
12 . The general syntax of a value-returning method is:
modifier(s) returnType
7
methodName(formal parameter list)
{
statements
}
13 . The line:
modifier(s) returnType methodName(formal parameter list)
is called the method heading (or method header). Statements enclosed
between braces, { and } , are called the body of the method.
14 . The method heading and the body of the method are called the definition
of the method.
15 . If a method has no parameters, you still need the empty parentheses in both
the method heading and the method call.
16 . A value-returning method returns its value via the return statement.
17 . A method can have more than one return statement. However, whenever
a return statement executes in a method, the remaining statements are
skipped and the method exits.
Search WWH ::




Custom Search