| Author |
C++ #include equivalent for Java
|
Gary Ba
Ranch Hand
Joined: Oct 23, 2009
Posts: 150
|
|
Hi,
If Class A has Class B, what do I need to do so Class A knows about Class B. I tried doing a simple inheretance program where I output a text on it's constructor but I am having a compile error on new ParentClass(). I dont have the actual compile error with me but I think it's what I have explain about. I tried searching it online but I couldn't find anything useful. Can anyone point me to the right direction.
Thank you.
|
star chaser..
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16692
|
|
Java doesn't have a concept of an include file, the compiler is smart enough to get the class details directly from the class files.
If the classB is in the same package as classA (or in the java.lang package), you don't have to do anything. The compiler will find it for you. Otherwise, you can specify the package of classB using the "import" statement.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Gary Ba
Ranch Hand
Joined: Oct 23, 2009
Posts: 150
|
|
Thank you. I got it to work.
|
 |
 |
|
|
subject: C++ #include equivalent for Java
|
|
|