I heard that using multiple import statements in a program affects its runtime performance. Is this true? If so, why?
4 Answers
Not at all. Imports are only used during compilation, the class files do not have them anymore.
3 Comments
GuruKulki
but the corresponding imported classes will be referred using fully qualified name then?
whiskeysierra
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.
Joey
Well, it imports the specified classes into the global namespace. From a language designer's viewpoint it may make sense, actually :-)
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.
2 Comments
Joey
While maybe a useful general tip it has no relation whatsoever to this question, actually.