Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By eRaaaa

Thread: Default constructor by compiler.

  1. #1
    manishdivs is offline Member
    Join Date
    Sep 2011
    Posts
    1
    Rep Power
    0

    Default Default constructor by compiler.

    Hi All,

    I know when we do not create any constructor then compiler creates a default constructor by its own.

    But when we create a parameterized constructor and not created a default one then compiler gives an error, why is it so??

    I mean, why default constructor is not created by compiler if we create a parameterized constructor.

    Many thanks in advance.

    Thank you-Manish

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Default constructor by compiler.


  3. #3
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Default constructor by compiler.

    That the compiler does not create a default constructor has a good reason, otherwise you can create an object and maybe important variables are not initialized.
    Example: You have a Person.class and you want that an object of this class is only legal if it has a first name and a last name....
    Last edited by eRaaaa; 09-19-2011 at 06:28 PM.
    Tolls likes this.

Similar Threads

  1. Copy Default table model to another default table model?
    By greatmajestics in forum AWT / Swing
    Replies: 2
    Last Post: 04-28-2010, 04:08 PM
  2. Replies: 1
    Last Post: 03-10-2009, 01:12 PM
  3. compiler,JIT compiler & interpreter
    By gamilah in forum New To Java
    Replies: 4
    Last Post: 11-04-2008, 12:32 AM
  4. Replies: 0
    Last Post: 12-19-2007, 09:10 AM
  5. Replies: 0
    Last Post: 12-19-2007, 09:01 AM

Posting Permissions

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