Java Reference
In-Depth Information
static Block
It is a compile-time error if a static initializer cannot complete normally (§ 14.21 ) .
It is a compile-time error if a return statement (§ 14.17 ) appears anywhere within a static ini-
tializer.
It is a compile-time error if the keyword this 15.8.3 ) or the keyword super 15.11 , § 15.12 )
or any type variable declared outside the static initializer, appears anywhere within a static
initializer.
Use of class variables whose declarations appear textually after the use is sometimes
restricted, even though these class variables are in scope. See § 8.3.2.3 for the precise
rules governing forward reference to class variables.
Exception checking for a static initializer is specified in § 11.2.3 .
8.8. Constructor Declarations
A constructor is used in the creation of an object that is an instance of a class (§ 12.5 ,
§ 15.9 ) .
ConstructorDeclaration:
ConstructorModifiers opt ConstructorDeclarator
Throws opt ConstructorBody
ConstructorDeclarator:
TypeParameters opt SimpleTypeName ( FormalParameterList opt )
The SimpleTypeName in the ConstructorDeclarator must be the simple name of the class
that contains the constructor declaration; otherwise a compile-time error occurs.
In all other respects, the constructor declaration looks just like a method declaration that
has no result type.
Constructor declarations are not members. They are never inherited and therefore are not
subject to hiding or overriding.
Example 8.8-1. Constructor Declarations
Click here to view code image
class Point {
int x, y;
Search WWH ::




Custom Search