I'm trying to learn Java using DrJava.
When I try to run this bit of code DrJava tells me:
Static Error: This class does not have a static void main method accepting String[].
What I don't get is why DrJava tells me there's no main. It's the first line after the class canine declaration; and I don't see any typos or missing punctuation.
I tried Googling this, but I didn't understand what they were talking about.
Would be nice if someone can clue me in, in a way that doesn't actually give me the answer, but leads me figure it out on my own why this is happening to me -but if the problem is too basic to create a learning opportunity, then I'll take a solution; I guess.
/*
* This is an exercise designed to practice creating a class Animal
* And then creating another class canine in which to create an object dog.
* The reason I want to call from one class to another is because I want
* to understand how classes, objects, inheritance, etc. works.
* Clearly, class canine is -in my mind at least, a child of class Animal.
* The main method of canine then calls method attributes I think are being
* inherited by dog and wolf,from the class Animal.
*/
public class Animal {
void growl() {
System.out.println("Grrr");
}
void bark() {
System.out.println("Arf! Arf!");
}
}
class canine {
public static void main(String[]args) {
Animal dog = new Animal();
dog.bark();
Animal wolf = new Animal();
wolf.growl();
}
}