aspose file tools*
The moose likes Beginning Java and the fly likes C++ #include equivalent for Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "C++ #include equivalent for Java " Watch "C++ #include equivalent for Java " New topic
Author

C++ #include equivalent for Java

Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 161

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: 18896
    
  40

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: 161

Thank you. I got it to work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: C++ #include equivalent for Java