Gary said:
The JLS says: If a class contains no constructor declarations, then a
default constructor that takes no parameters is automatically provided:
which is true. But if a class contains constructor declarations, you may
supply a default constructor that takes no parameters. I believe the use of
the word "default" means a constructor that takes no parameters, whether it
is explicit or implicit.
Specifically, the first part of JLS(2e) 8.8.7 says:
If a class contains no constructor declarations, then a _default
constructor_ that takes no parameters is automatically provided:
* If the class being declared is the primordial class Object, then
the default constructor has an empty body.
* Otherwise, the default constructor takes no parameters and simply
invokes the superclass constructor with no arguments.
A compile-time error occurs if a default constructor is provided by the
compiler but the superclass does not have an accessible constructor that
takes no arguments.
A default constructor has no throws clause.
It follows that is the nullary constructor of the superclass has a
throws clause, then a compile-time error will occur.
--- end quote ---
Emphasis on the first occurrence of "default constructor" is from the
source -- i.e. the quote is a *definition* of the term. A default
constructor is thus defined to be one provided automatically by Java for
some class, which happens when no other constructor is provided. It has
the properties of taking no arguments, throwing no checked exceptions,
and, except for the constructor for java.lang.Object, doing nothing but
invoking the superclass' no-argument constructor. (And note that the
superclass' constructor is not referred to as a "default constructor".)
Note also in the last sentence quoted, the use of the term "nullary
constructor" to refer to a constructor that takes no arguments.
It is true that some Java programmers rather loosely refer to any
nullary constructor as a default constructor, but this usage is
technically inaccurate, and no one who employs it should be shocked or
offended at being corrected. This is especially true in the context of
discussion occurring in some part in a Java-oriented technical forum
such as comp.lang.java.programmer.
John Bollinger
(e-mail address removed)