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: ConstructorModifiersopt ConstructorDeclarator Throwsopt ConstructorBodyConstructorDeclarator: TypeParametersopt SimpleTypeName (
FormalParameterListopt )
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.
Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.