KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was wondering why in java constructors are not inherited? You know when you have a class like this: public class Super { public Super(ServiceA serviceA, ServiceB serviceB, ServiceC serviceC){ this.serviceA = serviceA; //etc } } Later when you inherit from Super , java will complain that there is no default constructor defined. The solution is obviously something like: public class Son extends Super{ public Son(ServiceA serviceA, ServiceB serviceB, ServiceC serviceC){ super(serviceA,serviceB,serviceC); } } This code is repetitive, not DRY and useless (IMHO)... so that brings the question again: Why java doesn't support constructor inheritance? Is there any benefit in not allowing this inheritance?
Tags (comma-separated)
Save Edits
Cancel