aspose file tools*
The moose likes Beginning Java and the fly likes include class in other file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "include class in other file?" Watch "include class in other file?" New topic
Author

include class in other file?

Chris Weathers
Greenhorn

Joined: May 06, 2005
Posts: 12
In c++ we would #include "somefile.h" to get the classes in somefile.h included in the current program.

What is the Java equivalent? I couldn't find the answer in a tutorial I have been working through.
[ May 06, 2005: Message edited by: Chris Weathers ]
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
import


James Carman, President<br />Carman Consulting, Inc.
Chris Weathers
Greenhorn

Joined: May 06, 2005
Posts: 12
Doh! Thanks... so import "somefile.java"?
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
No,

import SomeClass;
Chris Weathers
Greenhorn

Joined: May 06, 2005
Posts: 12
Does SomeClass have to be compiled first?
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Yes.
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

...although if it isn't, the java compiler will compile it for you. (Provided it can find the .java file in the right place; this is one of the driving reasons that packages and directory structures must match....)


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: include class in other file?