Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

jdavidb
  (email not shown publicly)
http://voiceofjohn.blogspot.com/

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Friday January 11, 2008
11:58 AM

More about Java constructors

[ #35364 ]

Last entry, I noted that I'd never noticed before that Java subclasses don't inherit constructors. Now I just learned one reason why I probably hadn't noticed this: Java classes with no constructors explicitly defined will have an empty default constructor supplied for them by the compiler. (A default constructor is a constructor with no arguments.)

I mentioned that previously I'd wondered what had gone wrong when a couple of classes I was compiling from the command-line suddenly started giving me errors, and that the problem was that I thought constructors were inherited. In this case, what had happened was that every class in the inheritance hierarchy (it was an experiment in subclassing, among other things) was relying on this implicitly-supplied default constructor. Then I think I gave one of the classes a constructor that took arguments, but one of its subclasses was relying on it having a default constructor, which went away. Oops. :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.