Level 8 (Methods)


I don't get this level. It's asking me to: Add a method called bark to the Dog class (by typing: public void bark() {

}) and to type inside the bark method: System.out.println("Woof!");. How would I do this?
These are my lines of code:

class Dog {

int age;

public Dog(int dogsAge) {
age = dogsAge;


public static void main(String[] args) {

Dog spike = new Dog(5);



How would I correct this? Thanks!


Do this part first:

Type that bark method, exactly as shown above, put it before your Dog class's main method:


Is the main method: public static void main(String[] args) {? Sorry, I am still getting used to Java vocabulary.


Nevermind. Honestly though, somebody needs to get me a book all about Java for Dummies.


By the way @albionsrefuge, for level 9 what does it mean to call the 'bark' method on the 'spike' object?


There are a couple of things there that might need some explanation. It's hard to decide which order to present them in as they are intertwined.

  • The 'spike' object : this is the new Dog that you created when you did this: Dog spike = new Dog(3);

  • A method : a bit of code, a set of instructions, that sits there and does nothing until you call it, you can call it over and over again without having to rewrite the code

  • The 'bark' method : this is a bit of code that that prints out "Woof!" when you call it

  • Calling the bark method on spike : this goes and looks for that bark() method that is sitting there waiting for us, and processes the code inside it -- to call it you do it like this: spike.bark();


Thank you. Sorry if I am asking too many questions :confused:


I don't think that is possible, always ask questions. :wink:


Don't waste your money on textbooks. The internet has excellent learning resources for Java. Codecademy is not the only way to learn java. In fact, its pretty much crap in some of the concepts it presents.
If you want some professional courses, try Udacity or Coursera


Hi my name is Dimetric Johnson.

I am learning Java I see that u said that codecademy is pretty much not a good tool to learn with. will it not help me get my first job.


If you can learn enough then yes it will get you a new job