12.5
Creation of New Class Instances
EXECUTION
12.5   Creation of New Class Instances
A new class instance is explicitly created when one of the following situations
occurs:
Evaluation of a class instance creation expression ( 15.8) creates a new
instance of the class whose name appears in the expression.
Invocation of the
newInstance
 method ( 20.3.6) of class
Class
 creates a
new instance of the class represented by the
Class
 object for which the
method was invoked.
A new class instance may be implicitly created in the following situations:
Loading of a class or interface that contains a
String
 literal ( 3.10.5) may
create a new
String
 object ( 20.12) to represent that literal. (This might not
occur if the same
String
 has previously been interned ( 3.10.5).)
Execution of a string concatenation operator ( 15.17.1) that is not part of a
constant expression sometimes creates a new
String
 object to represent the
result. String concatenation operators may also create temporary wrapper
objects for a value of a primitive type.
Each of these situations identifies a particular constructor to be called with speci 
fied arguments (possibly none) as part of the class instance creation process.
Whenever a new class instance is created, memory space is allocated for it
with room for all the instance variables declared in the class type and all the
instance variables declared in each superclass of the class type, including all the
instance variables that may be hidden. If there is not sufficient space available to
allocate memory for the object, then creation of the class instance completes
abruptly with an
OutOfMemoryError
. Otherwise, all the instance variables in the
new object, including those declared in superclasses, are initialized to their default
values ( 4.5.4). Just before a reference to the newly created object is returned as
the result, the indicated constructor is processed to initialize the new object using
the following procedure:
1. Assign the arguments for the constructor to newly created parameter variables
for this constructor invocation.
2. If this constructor begins with an explicit constructor invocation of another
constructor in the same class (using
this
), then evaluate the arguments and
process that constructor invocation recursively using these same five steps. If
that constructor invocation completes abruptly, then this procedure completes
abruptly for the same reason; otherwise, continue with step 5.
228






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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