Create An Overload Constructor

You can have more than one constructor in a single class which is called OVERLOADING the class.  If you want to “construct” a CUSTOMIZED object instead of a PRE-DEFINED object each time you create an object, you can create one or more constructor that you can pass arguments into it to customize the object.

REPLACE LATER WITH OWN SCREENSHOT

EXAMPLE:

REPLACE ABOVE WITH MY CODE:

public class MyCustomBox {
// instance variables
public String height;
public String width;
public String depth;

// regular constructor method for 2D object
public MyCustomBox(String height, String width)
{
height = 100;
width = 100;
}

// overload constructor method for 3D object	
public MyCustomBox(String height, String width, String depth)
{
height = 100; 
width = 100;
depth = 100;
}
// Other methods here...
}

Now, create two pre-defined objects (a 2D and a 3D object) from the SAME class:

MyCustomBox my2DBox = new MyCustomBox();
MyCustomBox my3DBox = new MyCustomBox();

NOTES:

REPLACE LATER WITH OWN SCREENSHOT