Classes: Constructor Parameters


I am on part 5 of the OOP java. The task says :

“Add an int parameter called dogsAge in between the parentheses of the Dog() constructor.”

So my code is:

class Dog  {
  int age;
	public Dog (int dogsAge) {
    age = dogsAge;

	public static void main(String[] args) {


But it says this is wrong and it gives the error:

“Did you add the dogsAge parameter to the constructor?”

I do not understand what is wrong.


Assign the parameter to the variable, not the other way around.

age = dogsAge;


It still gives my the same error


Try writing it without a space before the parameter list…

public Dog(int dogsAge)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.