Methods I what does spike.bark(); stand for at the end. is it ever explained?


#1

class Dog {

int age;

public Dog(int dogsAge) {
age = dogsAge;

}

public void bark() {

System.out.println("Woof!");

}

public static void main(String[] args) {

Dog spike = new Dog(5);
spike.bark();

}

}


#2
  • spike is the name of the new Dog that you created (an object)
  • bark() is a bit of code that you wrote that prints "Woof!" when you call it (a method that is defined for all Dog objects)

#3

I left this out at the end I re-added spike.bark() from the last code.

spike.bark();
spike.run(40);

}

}


#4

Maybe if I take the spike.bark(); maybe it will work I am going to see, thanks for the assistance, I will let you know.


#5

Same thing, it is the code that CodeCademy placed in it, it works it just will not allow me to move to the next set of instructions


#6

Reset that exercise, then do one step at a time and click Run. When you get to the point where it doesn't work, please post a screenshot so we can see what you see.