abstract
| - 2.3.4 Constructors A constructor is used in the creation of an object that is an instance of a class: ConstructorDeclaration: ConstructorModifiersopt ConstructorDeclarator Throwsopt ConstructorBody ConstructorDeclarator: 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. Constructors are never invoked by method invocation expressions. Access to constructors is governed by access modifiers. Constructor declarations are not members. They are never inherited and therefore are not subject to hiding or overriding. It is a compile-time error to declare two constructors with override-equivalent signatures in a class. A compile-time error occurs if the same modifier appears more than once in a constructor declaration, or if a constructor declaration has more than one of the access modifiers public, protected, and private. Unlike methods, a constructor cannot be abstract, static, final, native, strictfp, or synchronized. The throws clause for a constructor is identical in structure and behavior to the throws clause for a method 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. Overloading of constructors is identical in behavior to overloading of methods.
|