parameterized-constructor

Why default constructor is not provided by compiler when class contains parametrized constructor defined by user? [duplicate]

只谈情不闲聊 提交于 2019-12-20 07:47:46
问题 This question already has answers here : Java default constructor (11 answers) Closed 8 months ago . I am a newbie in java and was wondering "Why default constructor is not provided by compiler when class contains parametrized constructor defined by user?" 回答1: When an author decides to not provide any constructor, it is perfectly fine that the compiler adds that default constructor. Obviously the user doesn't care "how" objects of that class are created, he accepts that the "default" kicks

Why default constructor is not provided by compiler when class contains parametrized constructor defined by user? [duplicate]

风流意气都作罢 提交于 2019-12-02 13:07:31
This question already has an answer here: Java default constructor 11 answers I am a newbie in java and was wondering "Why default constructor is not provided by compiler when class contains parametrized constructor defined by user?" When an author decides to not provide any constructor, it is perfectly fine that the compiler adds that default constructor. Obviously the user doesn't care "how" objects of that class are created, he accepts that the "default" kicks in. But as soon as the author writes down a constructor with parameters, it is also obvious that he assumes that one of his