Quick Index
Big Two


Recall the big three.

  • Method Name -- the name of the constructor (always matching the class name)
  • Method Parameters -- the method parameters that must be passed by the sender to this method (in this case two params -- both of type int)

Note: There is not a return type. The return type is implied. It is always equal to the given class type (in this example "Rectangle").

Example call of method:

Rectangle rec;
rec = new Rectangle(11, 5)
public 
1
Rectangle(
2
int aWidth, int aHeight)

Constructor Header vs Instance Method Header


We can see below that the primary difference between a "constructor" method header and an instance method header is that the constructor does not have a return type. We will learn that the return type is implicit.

Example 1
Constructor
public Rectangle(int aWidth, int aHeight)
Instance Method
public void growBy(int amount)


Example 2
Constructor
public Person(String aName)
Instance Method
public int max(int a, int b)