Darryl Burke wrote:Objects aren't ever static. References may be static.
Matthew Brown wrote:
Constructor objects are, but that's a bit different. Creating the object will still cause the constructor to be executed for the class you're instantiating and every super class.
Matthew Brown wrote:A SubA object is created (you only have one new statement, so you only create one object). But this SubA object is also a SuperA object.
Matthew Brown wrote:
Don't think of constructors as creating an object - I think that's what's causing your confusion. When a single object is created it's entirely possible that several constructors get run. It's better to think of constructors as initialising a new object. And even if a class is abstract, when it's instantiated via a subclass there might be initialisation code that needs to be run for it (e.g. instance variables declared in the superclass might need initialising).
?thread-safe lazy initialization idiom
Matthew Brown wrote:
adithya narayan wrote:The above thing compiles. I don't get how you are allowed to not specify a type of class while creating. According to the documentation:
But you are specifying a type: Class. that class itself is generic, which may be what is confusing you. But Class<? extends BaseSessionBean>, Class<EJB>, Class<String> all resolve to the same type: Class.
Matthew Brown wrote: And what compiler error are you getting? If Mediator isn't a subclass of BaseSessionBean then you won't be able to call the method because the signature doesn't match. If it is, something else is going on.