CLASSES
Constructor Modifiers
8.6.3
Constructors are invoked by class instance creation expressions ( 15.8), by
the
newInstance
method of class
Class
( 20.3), by the conversions and concate
nations caused by the string concatenation operator + ( 15.17.1), and by explicit
constructor invocations from other constructors ( 8.6.5). Constructors are never
invoked by method invocation expressions ( 15.11).
Access to constructors is governed by access modifiers ( 6.6). This is useful,
for example, in preventing instantiation by declaring an inaccessible constructor
( 8.6.8).
Constructor declarations are not members. They are never inherited and there
fore are not subject to hiding or overriding.
8.6.1 Formal Parameters
The formal parameters of a constructor are identical in structure and behavior to
the formal parameters of a method ( 8.4.1).
8.6.2 Constructor Signature
The signature of a constructor is identical in structure and behavior to the signa
ture of a method ( 8.4.2).
8.6.3 Constructor Modifiers
ConstructorModifiers:
ConstructorModifier
ConstructorModifiers ConstructorModifier
ConstructorModifier: one of
public protected private
The access modifiers
public
,
protected
, and
private
are discussed in 6.6.
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
,
or
synchronized
. A constructor is not inherited, so there is no need to declare it
final
and an
abstract
constructor could never be implemented. A constructor is
always invoked with respect to an object, so it makes no sense for a constructor to
be
static
. There is no practical need for a constructor to be
synchronized
,
because it would lock the object under construction, which is normally not made
available to other threads until all constructors for the object have completed their
177
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved