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
    9

    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
    14,051
    Blog Entries
    7
    Rep Power
    23

    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
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. constructors
    By droidus in forum New To Java
    Replies: 3
    Last Post: 04-28-2011, 08:14 PM
  2. Need help with constructors
    By tpfaff in forum New To Java
    Replies: 10
    Last Post: 10-22-2010, 04:33 AM
  3. Constructors
    By suresh.sa in forum New To Java
    Replies: 5
    Last Post: 10-20-2010, 12: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
  •