6
import java.io.*;
class Myclass
{
 //Some programming code that does not call any java io package methods or variables
}

Is that program takes more memory or even worse affect performance of the software/app than the program that has no unused imports?

M A
  • 71,713
  • 13
  • 134
  • 174
Javasamurai
  • 666
  • 7
  • 21
  • 2
    No. They just may the compiler work harder! With or without the unused import has no effect on the produced class file, which then has no effect on the runtime performance. – Brett Walker Jun 15 '15 at 13:45
  • See also [here](http://stackoverflow.com/questions/12620369/how-java-import-works). – Mena Jun 15 '15 at 13:47
  • Does that means it effects performance?Please elaborate. – Javasamurai Jun 15 '15 at 13:49
  • Also duplicate of this: http://stackoverflow.com/questions/18153690/does-an-unused-import-declaration-eat-memory-in-java – Stephen C Jun 15 '15 at 14:38

1 Answers1

3

No, imports are a compile-time feature (they have no meaning in the compiled code). They do not affect runtime behavior.

M A
  • 71,713
  • 13
  • 134
  • 174