dcsimg
Package FAQ-TCS
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kamal_maharana
Posted On:   Friday, September 15, 2006 06:31 AM

how can i access a file present in a package from a file present in a subpackage.
ex-: pkg1 -> test1.java
pkg1 ->pkg2 ->pkg3 ->test2.java
how can i access (test1.java) in (test2.java)

Re: Package FAQ-TCS

Posted By:   WarnerJan_Veldhuis  
Posted On:   Friday, September 15, 2006 07:14 AM

If you have different packages, you need to import the classes you need from that package. If you have a lot of classes, for example the Swing classes you can import the entire package. The compiler will find the classes it needs by searching the imports.

import javax.swing.*; //import everything
import pkg1.test1; //import only test1


Imports are always the first statements of a java file.



Side note: Study the naming conventions: class start with a Capital Letter.
About | Sitemap | Contact