SE450: Java: Constructors [2/41] Previous pageContentsNext page

Constructor is a special form of static method on an unformed object.

The constructor is always needed, and is always called on object creation

In java, the default no-arg constructor always exists, and is supplied by default by the language

If a constructor is supplied with arguments, a no-arg constructor will have to be supplied if needed, the default is no longer present. In general, write a no-arg constructor if you are using it.

an initialization block can be supplied to run code once. It is run before any constructor

Previous pageContentsNext page