encyclopegia.org

Nullary constructor

In computer programming, a nullary constructor is a constructor that takes no arguments. Also known as a 0-argument constructor, no-argument constructor, parameterless constructor or default constructor.

In computer programming, a nullary constructor is a constructor that takes no arguments. Also known as a 0-argument constructor, no-argument constructor, parameterless constructor or default constructor. ==Object-oriented constructors== In object-oriented programming, a constructor is code that is run when an object is created. Default constructors of objects are usually nullary. ===Java example=== public class MyInteger { private int data; // Nullary constructor public MyInteger() { this(0); } // Non-nullary constructor public MyInteger(int value) { this.data = value; } int getData() { return data; } void setData(int value) { data = value; } } ===C++ example=== class Integer { private: int data; public: // Default constructor with parameters // Leaving parameters unspecified defaults to the default value Integer(int value = 0): data{value} {} nodiscard int getData() const noexcept { return data; } void setData(int value) noexcept { data = value; } } ==Algebraic data types== In algebraic data types, a constructor is one of many tags that wrap data. If a constructor does not take any data arguments, it is nullary. ===Haskell example=== -- nullary type constructor with two nullary data constructors data Bool = False | True -- non-nullary type constructor with one non-nullary data constructor data Point a = Point a a -- non-nullary type constructor with... data Maybe a = Nothing -- ...nullary data constructor | Just a -- ...unary data constructor

References

No reference rows published for this article.

Cite this article

MLA

"Nullary constructor." encyclopegia.org, 2026, https://encyclopegia.org/wiki/nullary-constructor. Accessed 24 November 2026.

Chicago

"Nullary constructor." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/nullary-constructor.

APA

encyclopegia.org. (2026). Nullary constructor. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/nullary-constructor

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

constructor

stub · references available

Polyrhachis constructor

stub · references available

Soda Constructor

stub · references available

racecar constructor

stub · references available

MS Island Constructor

stub · references available

Constructor University

enwiki · references available

Copy constructor (C++)

enwiki · references available

Constructor (object-oriented programming)

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1360713875 · 0.5 · snapshot enwiki-001360713875

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.