3.3 Constructor Methods

Constructor Invocation

A constructor method is invoked only as part of a new expression when an instance object is first created. Each of these is a valid invocation of a ate an object OneRowNim constructor:

Annotation 2020-03-23 220317

The following constructor invocations are invalid because there are no matching constructor definitions:

Annotation 2020-03-23 220411

In the first case, there is no constructor method that takes a String parameter, so there’s no matching constructor. In the second case, there is no constructor that takes three int arguments. In both cases, the Java compiler would complain that there is no constructor method that matches the invocation.

Annotation 2020-03-23 220516