aspose file tools*
The moose likes Beginning Java and the fly likes Shortcut notation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Shortcut notation" Watch "Shortcut notation" New topic
Author

Shortcut notation

Charles Angemeyer
Greenhorn

Joined: Dec 18, 2012
Posts: 22
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

Joined: Mar 17, 2011
Posts: 7032
    
  16

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


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
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

    Joined: Jan 10, 2002
    Posts: 60050
        
      65

    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.


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Shortcut notation
     
    Similar Threads
    Input from keyboard
    Valid code, but what does it mean?
    Why can't my class see another class?
    ARGH! Package problem while using *
    converting a postfix to an infix