The Source for Java Technology Collaboration

As the new Java.net infrastructure contains project-level wikis, this main wiki will be shut down in the near future. For wiki page export and general wiki questions please contact the site admin at communitymanager@java.net.
Home | Help | Changes | Index | Search | Go

Default Versus No-Argument Constructors

Java makes a distinction between these two, which is often ignored.

A no-argument constructor is simply a constructor which takes no arguments.

The default constructor is a special kind of no-argument constructor. If no constructor whatsoever is provided by the programmer, then the system will always provide a default constructor, whose behavior is defined by this spec.

So, strictly speaking, a programmer can never write a default constructor (but they can certainly write a no-argument constructor).

-- JohnOHanley - 24 Jul 2003



Discussion about DefaultVersusNoArgumentConstructor

The above might be amended for this case: a no-arg constructor can have an implementation which simply mimics the behavior of the default constructor. -- JohnOHanley - 01 Aug 2003

Should "system" be replaced by the Java compiler since it's the compiler that will automatically insert a default constructor into the class file? -- Main.redwolf - 27 Aug 2003


Topic DefaultVersusNoArgumentConstructor . { Edit | Ref-By | Printable | Diffs r3 < r2 < r1 | More }
 XML java.net RSS

  

Revision r3 - 2003-08-27 - 17:59:42 - redwolf