7/13 Why can't I get past this error?

1 Like

The only thing that jumps out is the space

... = new Dog (9);


    Dog spike = new Dog(9);
1 Like

I removed the space, same error. Thanks for the suggestion…
It fetched the code which was EXACTLY the same as what I had so it seems to be a bug.

The instructions are looking for the required int parameter age where you have specified it as dogsAge. (Also, it may or may not be a problem, but your field age in the class has no accessibility modifier public/private/etc. Perhaps, for this lesson, set it to public (though keep in mind, often in “real life” you will need to have the modifier set to private.))

To get around clashing with the variables being named the same, you need to make use of this to refer to the current Class you are writing.


class Herald {
  private String name;
  public Herald(String name) {
    this.name = name; //"this" refers to the private field above and the other refers to the constructor parameter.
  public static void main(String[] args) {
    Herald joe = new Herald("Joe");
1 Like