| Author |
imports and performance
|
Dale DeMott
Ranch Hand
Joined: Nov 02, 2000
Posts: 514
|
|
Will having lots of classes to import slow down performance?  ------------------ What's this H2SO4 doing in my fridge?? ( thud )
|
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
|
 |
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6914
|
|
|
In general, no. It might slow down compilation a little, but once a class has been compiled and loaded it just references the other classes it needs directly, regardless of how many import statements were in teh source file.
|
A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
|
In C++ when you do an include, all the source is pulled into your code. That is not the case with java. Only the classes that you actually USE are pulled into the code. An import is more like a search path than a copy.
|
"JavaRanch, where the deer and the Certified play" - David O'Meara
|
 |
rani bedi
Ranch Hand
Joined: Feb 06, 2001
Posts: 358
|
|
cindi is correct the import statement just acts like a search path to reach to the class required. If you try to decompile a file you will notice that * in the import statement is replaced by the exact class names and the irrelevant import statements are deleted. test.java import java.util.*; import java.applet.*; class test { public static void main(String []args) { Date d = new Date(); System.out.println(d.getTime()); Vector v = new Vector(); System.out.println(v.capacity()); } } decompiled file test.class import java.io.PrintStream; import java.util.Date; import java.util.Vector; class test { test() { } public static void main(String []args) { Date date = new Date(); System.out.println(date.getTime()); Vector vector = new Vector(); System.out.println(vector.capacity()); } }
|
Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
|
 |
 |
|
|
subject: imports and performance
|
|
|