aspose file tools*
The moose likes Beginning Java and the fly likes package and import Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package and import" Watch "package and import" New topic
Author

package and import

stone eniac
Greenhorn

Joined: Dec 27, 2001
Posts: 3
based on JLS:
A single-type-import declaration imports a single named type, by mentioning its canonical name. A type-import-on-demand declaration imports all the accessible types of a named type or package as needed.

I want to know :
if I only use Vectorin package java.util,but I write instead of ,then will I pay more time on compiling and running the code?
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
hi,
In run time you don't need to worry, because it will not consume extra time because of importing all the content of package. But ofcouse at the time of compile time it will (But very negliable amount of time).
But i suggest import only that file which is need by your code. It is good programming practice.
-arun


Sharing is learning
stone eniac
Greenhorn

Joined: Dec 27, 2001
Posts: 3
many thanks to arun boraiah
again, is this only a programming practice?
which document can I find the specification about this?
[ February 05, 2002: Message edited by: stone eniac ]
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
hi,
I mentioned "good programing practice" because of following reasons
1. you will be sure that if in case more then one
class have same name placed in different package which is beeing imported.
2. By importing content of a package all by name. Helps to keep track of all class you are using.
Ofcouse also i feel i have read about using import with class name importing is good progrmming practice. But i don't remember where.
-arun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: package and import