constructor

A special method that runs when an object is created and receives whatever the object needs in order to exist.

In more detail

A class can have several constructors with different parameters. Declaring dependencies as constructor parameters is how a class insists on them, and the dependency injection container reads those parameters to build it.

Related terms

Taught in

References