View Single Post
  #1 (permalink)  
Old 09-08-2008, 07:51 AM
makbar24 makbar24 is offline
Member
 
Join Date: Sep 2008
Posts: 3
makbar24 is on a distinguished road
Super class and Subclass in same source file
hi forum,
I have a problem to compile the following code. i have declered a super class and its sub class in same file - called A.java. then i created a class file (wich conatin mail method) called - testInher.java. but when i try to compile by cmd, then it giving me following error:

file name : A.java
class A {

public void displayFromA()
{
System.out.println("I am a display message from class A- Parent");
}
}

class B extends A{

public void displayFromB()
{
System.out.println("I am a display message from class B- Child");
}
}


File name : testinher.java
public class testInher {

public static void main(String [] args)
{ B e = new B();
e.displayFromB();
}
}

cmd error msg:
"
C:\Test\Inher1>javac testInher.java
testInher.java:6: cannot find symbol
symbol : class B
location: class testInher
{ B e = new B();
^
testInher.java:6: cannot find symbol
symbol : class B
location: class testInher
{ B e = new B();
^
2 errors
"
here notice that: all are file in same directory and my classpath has been set up with".". i had tryed above code with IDE RAD and it compile and run over there.

i am wonder wht was i did wrong in that code??

Any help will be higly appriciated . looking forward ur reply . plz help me to learn java


thank you

Ovi
Reply With Quote
Sponsored Links