constructor

2 topics · 3 sources

Technology› Programming

Java

A constructor is automatically called when an instance of its class is created. A constructor always has the same name as its class, and has no return type. For instance

 public class Ship { public Ship(String name){ ... } ... } 
A class with no explicit constructor has an implicit no-arg constructor, which takes no arguments and has an empty body.

A pseudo-method that creates an object. In the Java programming language, constructors are instance methods with the same name as their class. Constructors are invoked using the new keyword.

Technology› Programming

Perl

Any "class method", instance "method", or "subroutine" that composes, initializes, blesses, and returns an "object". Sometimes we use the term loosely to mean a "composer".

Cite this definition

APA
MLA
Chicago