Java Reference
In-Depth Information
• Execution of a string concatenation operator (§ 15.18.1 ) that is not part of a con-
stant expression (§ 15.28 ) 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 (§ 8.8 ) to be called with specified
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
8.3 ) .
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.12.5 ) .
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 (§ 8.8.7.1 ) of an-
other 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.
3. This constructor does not begin with an explicit constructor invocation of another
constructor in the same class (using this ). If this constructor is for a class other than
Object , then this constructor will begin with an explicit or implicit invocation of a
superclass constructor (using super ). Evaluate the arguments and process that super-
class constructor invocation recursively using these same five steps. If that con-
structor invocation completes abruptly, then this procedure completes abruptly for
the same reason. Otherwise, continue with step 4.
4. Execute the instance initializers and instance variable initializers for this class, as-
signing the values of instance variable initializers to the corresponding instance
variables, in the left-to-right order in which they appear textually in the source
code for the class. If execution of any of these initializers results in an exception,
Search WWH ::




Custom Search