Help! stuck at 5/13


#1

Hi,
I'm stuck at the following exercise
https://www.codecademy.com/en/courses/learn-java/lessons/object-oriented-programming/exercises/classes-constructor-parameters

I keep getting the following error:
Set age equal to dogsAge inside of the constructor block. Use the example to help you.

here is my code:

class Dog {
  
  int age;

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


	public static void main(String[] args) {

	}

}


I am doing exactly like the example, so where am i wrong??


#2

Looks like a bug. Try copying the code you have > bottom right of screen > help > reset this exercise > paste code back in and run.

That should hopefully let you pass.


#3

I tried it, and I also tried to remove the spaces before ";" and "{"
It worked!

Thanks a lot! :smiley:


#4

I got stuck too. The following worked for me

class Dog {

int age;

public Dog(int dogsAge){
age = dogsAge;

}

public static void main(String[] args) {

Dog myDog = new Dog(1);

}

}


#5

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