*******************************************************

The syntax for coding constructors

public ClassName([parameterList]) { // the statements of the constructors } *******************************************************

Example 1: A constructor that assigns default values

public Product() { code = ""; description = ""; price = 0.0; } *******************************************************

Example 2: A custom constructor with three paramenters

public Product(String code, String description, double price) { this.code = code; this.description = description; this.price = price; } *******************************************************

Example 3: Another way to code the constructor shown above

public Product(String c, String d, double p) { code = c; description = d; price = p; } *******************************************************

Example 4: A constructor with one parameter

public Product(String code) { this.code = code; Product p = ProductDB.getProduct(code); description = p.getDescription(); price = p.getPrice(); } ******************************************************* Keep going, u are doing such a great job!!
Site hosted by Angelfire.com: Build your free website today!