<<< Example of calling a constructor | Index | Method Call Syntax >>> |
// one statement ClassName variableName = new ClassName(argumentList); // two statements ClassName variableName; variableName = new ClassName(argumentList);
For example,
Product book = new Product(); // or Product book; book = new Product(); // or String code = "ISBN:123-456-7890"; String description = "Short Novels"; double price = 5.0; Product book = new Product(code, description, price);
<<< Example of calling a constructor | Index | Method Call Syntax >>> |