Results 1 to 3 of 3

Thread: Constructors

  1. #1
    EdOBannon is offline Member
    Join Date
    Nov 2011
    Posts
    12
    Rep Power
    0

    Default Constructors

    How does constructor chaining work?

    How do you build objects from the inside out by calling constructors?

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: Constructors

    I'm confused by what you are asking, would you mind clarifying?

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,734
    Blog Entries
    7
    Rep Power
    21

    Default Re: Constructors

    A constructor can call another constructor in the same class with the this( ... ) syntax; the ellipses represent the parameters for the other constructor; the 'this( ... )' call has to be the first statement of the constructor that wants to call another constructor. Alternatively a constructor can call a constructor witht the super( ... ) syntax, also as the first statement of the calling constructor. If a constructor does none of these, the compiler generates a 'super()' call statement in the calling constructor. If all constructors call another constructor in the same class (with the this( ... ) construct), the compiler will complain about it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. constructors
    By droidus in forum New To Java
    Replies: 3
    Last Post: 04-28-2011, 09:14 PM
  2. Need help with constructors
    By tpfaff in forum New To Java
    Replies: 10
    Last Post: 10-22-2010, 05:33 AM
  3. Constructors
    By suresh.sa in forum New To Java
    Replies: 5
    Last Post: 10-20-2010, 01:10 AM
  4. Constructors?
    By annna in forum New To Java
    Replies: 3
    Last Post: 01-27-2010, 11:51 PM
  5. constructors
    By khamuruddeen in forum New To Java
    Replies: 2
    Last Post: 12-01-2007, 04:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •