JAVA: Using Methods: I


I am stuck at this lesson,
“Using Methods: I”

I followed instructions, inserted the:

However, after clicking on RUN, although the “Woof!” appear on console execution there is a message in red at the botton of screen:
“Did you call the bark method on the spike object? Make sure you call it inside of the main method.”

Well… I am stuck here… any help?

Thanks for the attention.
class Dog {
  int age;

	public Dog(int dogsAge) {
  	age = dogsAge;
  public void bark() {

	public static void main(String[] args) {
    Dog spike = new Dog(5);
    spike.bark();  // I inserted this code



It wants you to call things inside the main method, so that simply means don’t put it after
public static void main(String[] args) { .

As far as I know, the main method refers to what comes before that.

Yes that is the correct place to put the method.
Your code works for me, try running it again and seeing if you still have an error.

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