Type a constructor that initialises two fields
Type a constructor that initialises two fields
Answer
Dog(String name, int age) { this.name = name; this.age = age; }
this.name distinguishes the field from the parameter. No return type — not even void. Constructor name must match the class name exactly.