| Author |
package declaration
|
sam mitwa
Greenhorn
Joined: Mar 27, 2005
Posts: 13
|
|
i want to make one package of my own classes that i have made i know that classes of package are in one directory and i saw syntax package name (that u want to give ) i know this much ; now i m making one new class and than i want to import all the classes that i have made earlier by using package name ; one answer might be put all the classes tht u have made in the same directory than how can i import classes by package name ; my question is how can i make package of classes suppose i have 5 classes a b c d e how can i put these classes in one package whose name is p and now im making one new class z and now i want to use those classes(a,b,c,d,e) that i have put in package p how can i import ? i think that u can understand what i want to say ; i have already declared that how much knowledge i have about package im totally confused whether anyone can understand what i want to say : if anyone can understand what i want to ask please reply
|
 |
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
|
|
|
Moving to Java in General (Beginner).
|
SCJP Tipline, etc.
|
 |
Carol Enderlin
drifter
Ranch Hand
Joined: Oct 10, 2000
Posts: 1348
|
|
import p.*; //or import each one: import p.a; import p.b; import p.c; import p.d; import p.e; public class Z { }
|
 |
Raghu Shree
Ranch Hand
Joined: Mar 18, 2005
Posts: 143
|
|
Hi, you should define the package statement in a first executable line of the class file. If u have all classes in a single file then u should declared like below package p; class a{} class b{} ..... class f{} and all the class are should be placed in a folder p. or if u have individual files od each of class u should place the package p statement in every class file. If u want to import all the class in your file then u include following any one of the lines. import p.*; //It import all the class availabe in package p; (or) import p.a; import p.b; ... import p.e; // It import specified package class only. class z {} // Declaration of class Z I hope it will be useful to u. If u have any more dubts reply me. Regards Raghu Cheers!!!
|
Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
|
 |
 |
|
|
subject: package declaration
|
|
|