Problem with Object-Oriented Java 10


#1

https://www.codecademy.com/courses/learn-java/lessons/object-oriented-programming/exercises/methods-2?action=lesson_resume&link_content_target=interstitial_lesson

Ran into a problem on the first step of the exercise.

The instruction is the following:

In between the bark and main methods, add a method called run to the Dog class by typing:
public void run() {...}

Here is my code:


class Dog {
  
  int age;

	public Dog(int dogsAge) {
    
  	age = dogsAge;
    
  }
  
  public void bark() {
		
    System.out.println("Woof!");
    
	}
  
  public void run() {
    
  }

	public static void main(String[] args) {
    
    Dog spike = new Dog(5);
    spike.bark();

	}

}

As far as I can see, the bark method is in between the main and bark methods.

Error message:

Did you create the run method? Place it between the bark and main method.

I have no idea what to look for because as far as I know, I have completed the first instruction.
Heeeeeeeeeelp!

Thanks! :slight_smile:


3.10 - Methods II - Step One : "Did you create the run method?" error
#2

All good, I just had to complete the whole exercise at once.

For someone else who has the same problem, read the faded instructions to complete the whole exercise at once rather than step by step!


#3

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