my dog learned polymorphism*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 1815
...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.
 
wood burning stoves
 
subject: include class in other file?
 
Similar Threads
Question on SCJP 1.4 (CX-310-035) Scope
JSF Certification
Final packaging structure
Bit of Theory regarding Interfaces
how we can include one jsp page in another jsp Page?