File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Shortcut notation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 4753
    
    7

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?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32689
    
    4
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: 56201
        
      13

    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.


    [Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
     
    I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
     
    subject: Shortcut notation
     
    Similar Threads
    ARGH! Package problem while using *
    Valid code, but what does it mean?
    Why can't my class see another class?
    converting a postfix to an infix
    Input from keyboard