10

I heard that using multiple import statements in a program affects its runtime performance. Is this true? If so, why?

Joey
  • 344,408
  • 85
  • 689
  • 683
GuruKulki
  • 25,776
  • 50
  • 140
  • 201

4 Answers4

27

Not at all. Imports are only used during compilation, the class files do not have them anymore.

Jerome
  • 8,427
  • 2
  • 32
  • 41
  • but the corresponding imported classes will be referred using fully qualified name then? – GuruKulki Jan 04 '10 at 18:32
  • 5
    In fact the name "import" is badly choosen in this case, because you are not importing anything actually. You are just allowed to use a class/interface/enum/... by it's short (simple) name. Should be called "using" or "alias" or something like that. – whiskeysierra Jan 04 '10 at 18:36
  • Well, it imports the specified classes into the global namespace. From a language designer's viewpoint it may make sense, actually :-) – Joey Jan 04 '10 at 18:40
2

No, but importing more libraries than you need decreases the code readability.

Hamish Grubijan
  • 10,562
  • 23
  • 99
  • 147
1

Another reason is if you have a multiple import statements, this may hide the class relationship from the reader. Sometime it's nice to know that certain class doesn't depend on (directly) to some certain other classes.

nanda
  • 24,458
  • 13
  • 71
  • 90
-1

If you use IDE's like Netbeans it can mark out duplicate imports in the editor, that way you can remove it from code to make it more maintainable and also reduce compiler warnings.

omermuhammed
  • 7,365
  • 4
  • 27
  • 40