uday ramakrishna

Greenhorn
+ Follow
since Feb 24, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by uday ramakrishna

I am really sorry friends but I just tried what Jeff Albertson had posted and it compiled from the command prompt. I am not sure what is wrong when I compile it without the class path i.e when I directly compile it as javac Cat.java it does not compile. Could someone please tell me what settings I need to refine.

Thanks a ton for the soloution Jeff Albertson.

Best Regards
Uday
18 years ago
Thanks very much for all your responses. I am not using packages, but I am wondering if there is some porblem in the way JDK got installed and hence the problem. I ran several other examples and the same problems. I am not having an error when I compile files which inherit some custom classes from packages like AWT, SWING, etc.

Best Regards
Uday
18 years ago
Dear All,

I have been learning Java for a while now and I have run a few successful snippets on inheritance using extends keyword. But suddenly now I get the following error on running the subclass. This is a sample picked up from the java site directly. Could some one tell me what I am doing wronog? I am using textpad and j2sdk1.4.2_04

D:\RND\java\Cat.java:1: cannot resolve symbol
symbol : class Animal
location: class Cat
public class Cat extends Animal {
^
D:\RND\java\Cat.java:11: cannot resolve symbol
symbol : class Animal
location: class Cat
Animal myAnimal = myCat;
^
D:\RND\java\Cat.java:13: cannot resolve symbol
symbol : variable Animal
location: class Cat
Animal.hide(); //Better!
^
3 errors

Tool completed with exit code 1


//------------Base class
public class Animal {
public static void hide() {
System.out.println("The hide method in Animal.%n");
}
public void override() {
System.out.println("The override method in Animal.%n");
}
}

//------------Sub Class
public class Cat extends Animal {
public static void hide() {
System.out.println("The hide method in Cat.%n");
}
public void override() {
System.out.println("The override method in Cat.%n");
}

public static void main(String[] args) {
Cat myCat = new Cat();
Animal myAnimal = myCat;
myAnimal.hide(); //BAD STYLE
Animal.hide(); //Better!
myAnimal.override();
}
}

Please tell me what is wrong and why I am getting an error.

Regards
Uday
18 years ago