>It is not a hierarchy even though it looks like one.
>> It is not a hierarchy even though it looks like one.
>
> what ? which one is not hierarchy ?
Packages in general.
> i can save files here "com/pack1/packe2/pack3" folder with a package
> statement "package com.pack1.packe2.pack3; " in all my java files.
This is just a convention used by most Java IDE's and standard class
loaders. But you should remember that packages != directories. You can
place your class files everywhere you like as long as you make sure they
are accessible via some class loader. Of course, there are some drawbacks
in putting all class files in a single directories (size and nameclashes
to name some).
What Roedy tried to convey is that there is no hiearchy of packages
although the dotted notation makes it look like there was. Packages are
just sitting beside each other. package com.foo.bar is not an inner
package to com.foo and has no provileged access to it.
> i can save files here "com" folder with a package statement "package
> com; " in all my java files.
[quoted text clipped - 4 lines]
> import com.pack1.packe2.pack3.*;
> import com.*;
None of them. You need
import com.pack1.*;
or
import com.pack1.YourClass;
> i did not understand what do you mean by hierrarchy
Hope I could clear this up a bit.
Kind regards
robert
gk - 11 Jan 2006 11:47 GMT
hi, i am more confused.
is my question clear to you guys ?
here i am reposting it again
code 1:
--------
package com.pack1.packe2.pack3;
class klass1
{
// code
}
this code has been saved in com/pack1/packe2/pack3 directory.
code 2:
--------
package com;
class klass2
{
// code
}
this code has been saved in com directory.
code 3:
--------
package com.pack1;
import com.pack1.packe2.pack3.*; // is this OK
import com.*; // // is this OK
class MyClass
{
// i want to use klass1 and klass2 here. so, how do i import those
classes now ? is now import statement correct ?
}
this code has been saved in com/pack1 directory.
Chris Smith - 11 Jan 2006 16:15 GMT
[...]
> package com.pack1;
>
[quoted text clipped - 9 lines]
>
> this code has been saved in com/pack1 directory.
Yep, you're fine.
(If you want additional nitpicking, it's a good idea to avoid wildcard
imports because they can lead to compatibility problems in later code.
However, wildcards do work.)

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation