Importing too much?

Hi,

Just a general question about the "import" statement.

Does the amount of classes imported into a java file, or the number of individual import statements, influence the size of the generated class file?

For example, would a file that included the statement "import java.swing.*" make a bigger or smaller or equal-sized class file, compared to one that included individual import statements for each Swing class that was actually used?

What sort of overhead is there for an import statement?

Ben

[536 byte] By [bjnew] at [2007-9-27 22:00:46]
# 1

No, the class file will stay the same regardless. It doesn't matter if you import a single class or the whole package, there will be no effect on the class file. It can however slow down the time taken to compile it into a class file if you import a whole package instead. Still, even that isn't usually noticable.

Ceranith at 2007-7-7 11:53:19 > top of Java-index,Archived Forums,Java Programming...
# 2
FYI, some more information on how the import statement works: http://developer.java.sun.com/developer/TechTips/2000/tt0110.html#tip2
hungyee at 2007-7-7 11:53:19 > top of Java-index,Archived Forums,Java Programming...
# 3
In java is not like C, importing is only telling that use it.That is why you allways need everything in your classpath, cause you dont realy import it in your class file.qkfeto
qkfeto at 2007-7-7 11:53:19 > top of Java-index,Archived Forums,Java Programming...
# 4
Thanks.I suspected that was the case :-)
bjnew at 2007-7-7 11:53:19 > top of Java-index,Archived Forums,Java Programming...