× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Why aren't abstract constructors allowed?

James Jensen
Feb 10, 2015
<p>Any constructor you create must be called by any class that implements this abstract class, so there's not really a need to "remind" people to implement that constructor. </p> <p>There are a lot of reasons that people extending your classes might want to create their own constructors. For example:</p> <pre><code>public MySpecialSize16Font() { super(16); } </code></pre> <p>or</p> <pre><code>public ColoredFont(int size, Color color) { super(size); this.color = color; } </code></pre> <p>It's not really your place to specify what constructors these classes can and cannot provide.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/27907772/Why%20aren't%20abstract%20constructors%20allowed?/27907812">Stack Overflow</a>.</p>
comments powered by Disqus