Re: acces of members of subclass



Lew wrote:
The call to super() is *always* present.  Any given class, in the
general case, can rely on the presence of super() call.  Daniel and
you are not correct.

Eric Sosman <Eric.Sos...@xxxxxxx> wrote:
     No, Mark is right, and Daniel and Lew are wrong.

I said that there was a call. I never claimed that it would always
succeed.

     Lew (and the JLS) are right in saying that the compiler inserts a
call to super() if the constructor does not begin with a call to one

How can I be wrong if I said the same thing that the JLS does?

of its superclass' constructors.  But that does not guarantee that the
superclass actually *has* a no-arguments constructor that can be called
as plain super().  If it doesn't, there'll be a compile-time error.

I never said otherwise.

Try it!

The error that results proves that I was correct. There cannot be an
error on a call to super() unless there's a call to super() to have an
error.

--
Lew



.



Relevant Pages

  • Re: what is the RIGHT THING to make a constructor of a subclass, using super()
    ... If you are left with that requirement as a necessary or desirable part of the design, then the usual approach is probably to write a static method in the class that you call as an argument to the call to super() from your constructor. ... public Customer(String firstName, String lastName) { ... public class SlashSeparatedCustomer extends Customer { ...
    (comp.lang.java.programmer)
  • Re: what is the RIGHT THING to make a constructor of a subclass, using super()
    ... If you are left with that requirement as a necessary or desirable part of the design, then the usual approach is probably to write a static method in the class that you call as an argument to the call to super() from your constructor. ... public Customer(String firstName, String lastName) { ... public class SlashSeparatedCustomer extends Customer { ...
    (comp.lang.java.programmer)
  • Re: "x.constructor == Foo" vs "x instanceof Foo"
    ... statement does not add Super.prototype to the prototype chain of Sub ... Sub.prototype = new Super(); ... var sub1 = new Sub; ... not from constructor objects. ...
    (comp.lang.javascript)
  • Re: [General]acces of members of subclass
    ... I speak a little French and I thought "membre" was a direct translation of the English "member", and many people make the same confusion in English that you did, so I suspect it's not a translation problem. ... Super sub = new Sub; ... such "super constructor" must start with super ... public class Sub extends Super ...
    (comp.lang.java.help)
  • Re: A class that uses instances of itself? Is this right?
    ... > constructor uses supereven though it doesn't extend anything ... The call to super() is logically unnecessary, but it does no harm (especially ... is used internally to implement the new enum classes in Java 5.0. ... One particular advantage of the technique is that the instances can be compared ...
    (comp.lang.java.programmer)