I have 3 class file, when i compile the class which extends the other class gives compilation error like symbol not found.
public class Animal {
public static void hide() {
System.out.println("Hide Method Of Animal");
}
public void override() {
System.out.println("The Override method of Animal");
}
}
public class Cat extends Animal {
public static void hide() {
System.out.println("Hide Method Of Cat");
}
public void override() {
System.out.println("The Override method of Animal");
}
}
public class TestAnimal {
public static void main(String args[]) {
Cat myCat = new Cat();
Animal myAnimal = (Animal)myCat;
myAnimal.hide();
myAnimal.override();
}
}
I get this error:
TestAnimal.java:6: cannot find symbol
symbol : class Cat
location: class com.Test.TestAnimal
Cat myCat = new Cat();
^
Any help on this???
Yes, see if there is a .class file for each .java file after you compile. If not, make sure that each one has a .class file.
When you run, use the -classpath argument to point to the directory where all the .class files live.
You sound like you could use some instruction on compiling and running Java.
http://www.horstmann.com/bigj/help/compiler/tutorial.html
Here’s the spoon feeding answer:
shell.