• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Import  RSS feed

 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is there any hit on performance when we say something like

importjava.io.*;

I mean is there any hit when we try to import many classes that may not be used in the program.
 
John Melton
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should not be any runtime performance hit. The compiler should do the work for you of seeing what individual classes you're looking for and loading those into the bytecode. It should not load other classes for you that are in the global package.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there is definitely no performance hit at runtime - no matter how many classes you import.
 
Chris Corbyn
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a readability point of view you're far better importing only what you need though. I like to be able to open a file and see what interfaces it depends upon.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!