• Post Reply Bookmark Topic Watch Topic
  • New Topic

what would be the impact by importing a specific class rather than an entire package ?  RSS feed

 
Birla Murugesan
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what would be the impact by importing a specific class rather than an entire package ?

Is there is any benefits by doing so?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clarity through specificity.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no 'impact' per say, as long as you import individually the classes you need then that's fine. Many people find importing packages easier because that way they don't have to hunt and peck their way through exactly what classes they need.

There's very little performance difference between the two methods, in fact it's a really trivial difference in modern JDKs.
 
Birla Murugesan
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whether it makes any differences in the generated class files ?
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Birla Murugesan wrote:whether it makes any differences in the generated class files ?
Imports are used by the compiler, not the JVM, so I don't think there is any difference, but you could check that by using javap with (I think) the -p option.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!