Reputation: 75
when i looked at the source code of Scanner in java i found something confused me
import java.nio.file.Path;
import java.nio.*;
what is the difference between them, why they didn't just imported java.nio.*? thank you.
Upvotes: 2
Views: 142
Reputation: 272517
Wildcards are not recursive. import java.nio.*
imports everything directly under java.nio
, but not any deeper than that.
In fact, "deeper" is a misleading term in itself. Packages in Java don't form a hierarchy - they aren't really nested in any semantic way. java.nio.file
and java.nio
are no more related to each other than foo
and bar
are to each other.
Upvotes: 8
Reputation: 19926
java.nio.*
only imports the classes in that package
but not in its subpackages
.
Upvotes: 1