Java Reference
In-Depth Information
A constructor is generic if it declares one or more type variables (§ 4.4 ) .
These type variables are known as the type parameters of the constructor. The form of the
type parameter section of a generic constructor is identical to the type parameter section of
a generic class (§ 8.1.2 ) .
A generic constructor declaration defines a set of constructors, one for each possible in-
vocation of the type parameter section by type arguments. Type arguments may not need to
be provided explicitly when a generic constructor is invoked, as they can often by inferred
15.12.2.7 ) .
The scope and shadowing of a constructor's type parameter is specified in § 6.3 and § 6.4 .
8.8.5. Constructor Throws
The throws clause for a constructor is identical in structure and behavior to the throws clause
for a method (§ 8.4.6 ) .
8.8.6. The Type of a Constructor
The type of a constructor consists of its signature and the exception types given its throws
clause.
8.8.7. Constructor Body
The first statement of a constructor body may be an explicit invocation of another con-
structor of the same class or of the direct superclass (§ 8.8.7.1 ).
ConstructorBody:
{ ExplicitConstructorInvocation opt BlockStatements opt }
It is a compile-time error for a constructor to directly or indirectly invoke itself through a
series of one or more explicit constructor invocations involving this .
If the constructor is a constructor for an enum type (§ 8.9 ) , it is a compile-time error for it
to invoke the superclass constructor explicitly.
If a constructor body does not begin with an explicit constructor invocation and the con-
structor being declared is not part of the primordial class Object , then the constructor body
implicitly begins with a superclass constructor invocation “ super(); ”, an invocation of the
constructor of its direct superclass that takes no arguments.
Except for the possibility of explicit constructor invocations, the body of a constructor is
like the body of a method (§ 8.4.7 ) .
Search WWH ::




Custom Search