<<< A custom constructor | Index | A constructor with one parameter >>> |
A better programming style might be to name the constructor parameters exactly as the class data members:
public Product(String code, String description, double price) { this.code = code; this.description = description; this.price = price; }
To disambiguate between local constructor parameters and object's member variabled the this keyword is applied in front of the data field names.
<<< A custom constructor | Index | A constructor with one parameter >>> |