Java Reference
In-Depth Information
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 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
8.8.5. Constructor Throws
The
throws
clause for a constructor is identical in structure and behavior to the
throws
clause
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
.
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