Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package and import

 
stone eniac
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
stone eniac
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic