Skip to content
Main menu
  • Main page
  • Discover
  • Unexpected connections
  • Topics
  • Random article
  • Search
Your library
  • Saved articles
  • Recent discoveries
  • Rabbit-hole trails
Topic areas
  • Computer Science
  • Mathematics
  • Physics
  • Engineering
  • Biology
  • Economics
  • Curiosities
WikiholeDeeper into Wikipedia
EnglishEN
  • Saved
  • History

  • Article text and media come live from Wikipedia via the official MediaWiki API and are available under the Creative Commons Attribution-ShareAlike 4.0 License; additional terms may apply. Each article links to its source and revision.
  • WikiHole is an independent project and is not affiliated with the Wikimedia Foundation.
  • How ranking works
  • All topics
  • Reading history
  • Random article
  • MediaWiki API

Nullary constructor

  • Article
  • Rabbit hole
  • Read
  • View history
Tools
Actions
  • Read
  • View history
General
  • Recent changes
  • Related articles
  • Random discovery
This article
Reading time
1 min
Topic
Computer Science
Views
63 in 14 days
Last edited
23 Jun 2026
Print/export
  • Printable version
In other projects
  • Wikidata item
From Wikipedia, the free encyclopedia
Rabbit hole:
  1. Nullary constructor

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

Loading the rest of the article…

Recent changes

Rabbit hole

Where Nullary constructor leads. Every connection below has a source: a link in this article, a shared Wikipedia category, or CirrusSearch text similarity. Articles already on your trail are left out.

Contents
  • (Top)
  • Object-oriented constructors
  • Algebraic data types
  • See also
  • References
  • Recent changes
  • Rabbit hole
Contents
Contents6 sections
  • (Top)
  • Object-oriented constructors
  • Java example
  • C++ example
  • Algebraic data types
  • Haskell example
  • See also
  • References
  • Recent changes
  • Rabbit hole

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.4

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

See also

  • Default constructor

References

  1. 1"Default Constructor in Java – Class Constructor Example". freeCodeCamp.org. 2022-01-13. Retrieved 2022-03-23.
  2. 2"No-argument Constructor". chortle.ccsu.edu. Retrieved 2022-03-23.
  3. 3"Default constructors - cppreference.com". en.cppreference.com. Retrieved 2023-04-12.
  4. 4Ottinger, Joseph B.; Linwood, Jeff; Minter, Dave (2022), "An Introduction to Hibernate 6", in Ottinger, Joseph B.; Linwood, Jeff; Minter, Dave (eds.), Beginning Hibernate 6: Java Persistence from Beginner to Pro, Berkeley, CA: Apress, pp. 1–25, doi:10.1007/978-1-4842-7337-1_1, ISBN 978-1-4842-7337-1, retrieved 2022-03-23
Study aids for Nullary constructor

Terminology

0-argument constructor
Also known as a 0-argument constructor, no-argument constructor, parameterless constructor or default constructor.
no-argument constructor
Also known as a 0-argument constructor, no-argument constructor, parameterless constructor or default constructor.
parameterless constructor
Also known as a 0-argument constructor, no-argument constructor, parameterless constructor or default constructor.
default constructor
Also known as a 0-argument constructor, no-argument constructor, parameterless constructor or default constructor.

Terms the article defines in bold, quoted in context.

Categories:
  • Method (computer programming)
  • Computer science stubs

74 words · 4 references · revision 1360713875 · CC BY-SA 4.0

General
  • Recent changes
  • Related articles
  • Random discovery
This article
Reading time
1 min
Topic
Computer Science
Views
63 in 14 days
Last edited
23 Jun 2026

Key concepts

  • Constructor (computer science)2
  • Computer programming1
  • Parameter (computer science)1
  • Object-oriented programming1
  • Object (computer science)1
  • Default constructor1
  • Algebraic data types1

The articles this one links to most, weighted towards the introduction.

Print/export
  • Printable version
In other projects
  • Wikidata item
Created
10 Dec 2006
History
65 edits
39 contributors
No edits in the last 30 days
Last edited
23 Jun 2026

65 revisions in total · 39 contributors

  1. 23 Jun 2026, 03:48 UTCCitationCleanerBotmclean up of :Category:CS1 maint: work parameter with ISBN, see Wikipedia:Bots/Requests for approval/CitationCleanerBot 7+18diff
  2. 6 Sept 2025, 21:46 UTCAnonymous contributorNo edit summary+42diff
  3. 6 Sept 2025, 21:31 UTCAnonymous contributor§ Java example+519diff
  4. 27 May 2025, 18:21 UTCOAbotmOpen access bot: url-access updated in citation with #oabot.+25diff
  5. 2 Nov 2024, 12:06 UTCTom.RedingmWP:STUBSPACING followup+1diff
  6. 9 Feb 2024, 08:42 UTCWikiCleanerBotmv2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)0diff
  7. 7 Feb 2024, 13:18 UTCAnonymous contributorembolden+6diff
  8. 7 Feb 2024, 13:17 UTCAnonymous contributoradded parameterless constructor as alt - is commonly referred to this way in e.g. C#+27diff

View full revision history

Created
10 Dec 2006
History
65 edits
39 contributors
No edits in the last 30 days
Last edited
23 Jun 2026

Related articles are unavailable right now.

Wikipedia is rate limiting us right now. Try again in a minute.