Sami Devine wrote:This code compiles fine. I have saved the whole block as Animal1.java When I try to run it as java Animal1 I get Exception in main error.
It might help if you put all of your classes (including the interface) in a separate file. But as is, I changed your TestAnimals class to public and saved it to TestAnimals.java and it worked fine for me. I also took the public modifier off the Animal1 class.