2018-02-03

Class
In general, class declarations can include these components, in order:
1.Modifiers such as public, private, and a number of others that you will encounter later.
2.The class name, with the initial letter capitalized by convention.
3.The name of the class's parent (superclass), if any, preceded by the keyword extends. A class can only extend (subclass) one parent.
4.A comma-separated list of interfaces implemented by the class, if any, preceded by the keyword implements. A class can implement more than one interface.
5.The class body, surrounded by braces, {}.

There are several kinds of variables:
•Member variables in a class—these are called fields.
•Variables in a method or block of code—these are called local variables.
•Variables in method declarations—these are called parameters.

More generally, method declarations have six components, in order:
1.Modifiers—such as public, private, and others you will learn about later.
2.The return type—the data type of the value returned by the method, or void if the method does not return a value.
3.The method name—the rules for field names apply to method names as well, but the convention is a little different.
4.The parameter list in parenthesis—a comma-delimited list of input parameters, preceded by their data types, enclosed by parentheses, (). If there are no parameters, you must use empty parentheses.
5.An exception list—to be discussed later.
6.The method body, enclosed between braces—the method's code, including the declaration of local variables, goes here.

Definition: Two of the components of a method declaration comprise the method signature—the method's name and the parameter types.

你可能感兴趣的:(2018-02-03)