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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 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
    
  19

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: C++ #include equivalent for Java
 
Similar Threads
Need help in javax.mail package.......very urgent
import
Getting a servlet file to compile
compile
mock exam problem