dcsimg
== Does "import" statments order has any effect? ==
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   laeticia_corlean
Posted On:   Friday, October 4, 2002 01:48 AM

Hi, In C++ for instance, the order of the "#include" directives have a meaning a.k.a if an include file is included before an other one, we can observe tricky problems. Furthermore it is recommended not to abuse of them (using unnecessary includes might cause redefinitions problems). How about JAVA? Is the order of the import statments important? Does it slow the final precompiled code down if too many of them are included? Is it better to use several: import java.util.Vector; import java.util.Hashtable; [...] rather than one single import java.util.*; Thanks    More>>

Hi,


In C++ for instance, the order of the "#include" directives have a meaning a.k.a if an include file is included before an other one, we can observe tricky problems. Furthermore it is recommended not to abuse of them (using unnecessary includes might cause redefinitions problems).


How about JAVA?

Is the order of the import statments important?
Does it slow the final precompiled code down if too many of them are included?


Is it better to use several:


import java.util.Vector;

import java.util.Hashtable;

[...]


rather than one single


import java.util.*;



Thanks

   <<Less

Re: == Does "import" statments order has any effect? ==

Posted By:   Lasse_Koskela  
Posted On:   Friday, October 4, 2002 01:51 AM

The performance of the compiled code is dependent on the compiler, I guess. I would assume that the compiler "drops" the unused imports.


As it comes to importing explicit classes/whole packages, well, it's a matter of taste, I think.


Importing each class explicitly offers the benefit of easier understanding of dependencies for a new developer.
On the other hand, having 50+ imports in the beginning of the source file can be annoying...

About | Sitemap | Contact