• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Shortcut notation

 
Charles Angemeyer
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recently I was experimenting with Bufferedreader and came across a web example that you see below.
(I only included the top part of the code).
My question is this: Wouldn't I want to use some abreviation notation for the import statements?
Wouldn't import.java.io.* be better than listing each out individually? Many thanks.

 
Winston Gutkowski
Bartender
Pie
Posts: 9461
49
Eclipse IDE Hibernate Ubuntu
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Charles Angemeyer wrote:My question is this: Wouldn't I want to use some abreviation notation for the import statements?
Wouldn't import.java.io.* be better than listing each out individually?

You certainly can, but I tend not to; and it sounds like you're probably using an IDE, most of which create them as you've shown.

I guess my question to you is: why would you bother? The savings are ONLY at compile time (and even then we're talking milliseconds); it makes absolutely no difference whatsoever to your runtime class.

Winston
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using individual imports has two advantages.
  • 1: You have a list of classes (etc) used in your application (or at least in the current class).
  • 2: There is less risk of collisions, eg between Timers.
  •  
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64178
    83
    IntelliJ IDE Java jQuery Mac Mac OS X
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Campbell Ritchie wrote:Using individual imports has two advantages.
  • 1: You have a list of classes (etc) used in your application (or at least in the current class).
  • 2: There is less risk of collisions, eg between Timers.


  • This. I always list them out individually. My IDE can hide them during editing if they seem to be in the way, but that is rare.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic