• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

C++ #include equivalent for Java

 
Gary Ba
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Henry Wong
author
Marshal
Pie
Posts: 21192
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gary Ba
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I got it to work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic