SCJP2
Co-Author of Head First Design Patterns
Just a Jini girl living in a J2EE world.
SCJP1.4
Originally posted by Kathy Sierra:
Remember that a private constructor makes a class essentially final, since no other class can extend it.
Co-Author of Head First Design Patterns
Just a Jini girl living in a J2EE world.
An explicit constructor invocation statement in a constructor body may not refer to any instance variables or instance methods declared in this class or any superclass, or use this or super in any expression; otherwise, a compile-time error occurs.
SCJP2. Please Indent your code using UBB Code
Originally posted by Jose Botella:
Can I respond? Can I ?![]()
From JLS 8.8.5.1
It is not safe to use an instance before the contruction of its super classes, because its instance fields are not yet initialized. The execution of the instance (variable) initializers of a class do not begin until the super() or possible this() invokations complete.
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
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.5.5).
SCJP2. Please Indent your code using UBB Code
Originally posted by Jose Botella:
Exactly as JLS 12.5 says
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
SCJP2. Please Indent your code using UBB Code
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
Co-Author of Head First Design Patterns
Just a Jini girl living in a J2EE world.
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
SCJP2. Please Indent your code using UBB Code
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
Originally posted by Mocha D'Late:
I don't clearly understand what the purpose of a private constructor is? Can anyone share their knowledge please?
Co-Author of Head First Design Patterns
Just a Jini girl living in a J2EE world.
Originally posted by Jose Botella:
Anyway, Ron's right; if the method was overriden the executing method could be one in the subclass that relies on instance fields of the subclass not yet initialized.
Co-Author of Head First Design Patterns
Just a Jini girl living in a J2EE world.
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |