• Post Reply Bookmark Topic Watch Topic
  • New Topic

Importing entire package vs importing specific class/interface  RSS feed

 
Shriniwas Mujumdar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we consider following import statements then is there any differnce between them from the code performance point of view:










Thanks in advance,
Shriniwas
 
Henry Wong
author
Sheriff
Posts: 23289
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In terms of performance, meaning running the code? None. Importing is related to compilation -- not runtime.

Henry
 
fred rosenberger
lowercase baba
Bartender
Posts: 12558
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"imports" in java are NOT the same as "includes" in C. in "C", the included file is basically copied into the original file, thus potentially bloating the code.

In java, all an import does is tell the compiler "instead of writing the fully qualified name, i'm going to use a shorthand". It may slow down the compiling of the program, but it won't slow down the execution of it.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!