Nullary constructor

From Wikipedia, the free encyclopedia

A nullary constructor is a constructor that takes no arguments.

[edit] Java example

public class Example 
{
  /* nullary constructor */
  public Example ()
  {
     this.data = 1;
  }
  
  /* non-nullary constructor */
  public Example (int data)
  {
     this.data = data;
  }
  
  protected int data;
}

[edit] Haskell example

-- nullary type constructor with two nullary data constructors
data Bool = False
          | True

-- non-nullary type constructor with non-nullary data constructor
data Point a = Point a a

-- nun-nullary type constructor with...
data Maybe a = Nothing  -- ...nullary data constructor
             | Just a   -- ...unary data constructor