Speed Isse: importing vs. declaration in code

Is it more efficient to have for example java.io.FileReader myReader in the code as opposed to importing it at the top of the program? I am trying to speed up a GUI application and was wondering how to speed up the startup time of my program.

[249 byte] By [seanmu13a] at [2007-11-27 11:35:42]
# 1

imports dont effect "performance" or "efficiency".

TuringPesta at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 2

> imports dont effect "performance" or "efficiency".

Definitely not with respect to runtime. It *may* have affect at compile-time, but it's not likely to be noticeable.

~

yawmarka at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 3

But if i took out all of the import statements and explicitly named the classes each time I needed to would that improve startup time at all?

seanmu13a at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 4

> But if i took out all of the import statements and

> explicitly named the classes each time I needed to

> would that improve startup time at all?

No. There is no difference at runtime.

~

yawmarka at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 5

> But if i took out all of the import statements and

> explicitly named the classes each time I needed to

> would that improve startup time at all?

No.

Importing has ZERO effect at runtime. The generated bytecode will be exactly the same whether you import *, import named classes, or import nothing.

All importing does is save you typing and make your clode less cluttered by telling the compiler that when you say, e.g., "List", you mean "java.util.List."

jverda at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 6

Alright, thanks everybody. Do you have any tips on improving GUI start time that you'd like to share? Thanks

seanmu13a at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 7

maybe a better question would be, "what can one do to decrease start-up time?"

edit - too slow

BigDaddyLoveHandlesa at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 8

I remember being told about an office building were there were complaints

about the waiting time for elevators. The cost of putting in another elevator

was huge, so they came up with an alternate plan: they installed mirrors

by the elevators.

BigDaddyLoveHandlesa at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 9

Yea, load JFileChooser in the background before you ever have to use it.

On Windows it takes FOREVER to pop-up the first time.

TuringPesta at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 10

touche my friend

seanmu13a at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 11

> I remember being told about an office building were

> there were complaints

> about the waiting time for elevators. The cost of

> putting in another elevator

> was huge, so they came up with an alternate plan:

> they installed mirrors

> by the elevators.

Priceless.

~

yawmarka at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 12

i dont get it, lol.

people spent the time looking at themselves?

or did they spend all their time trying to press the buttons

reflected in the mirrors? ;)

TuringPesta at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 13

In other words, why not add a splash screen :-)

BigDaddyLoveHandlesa at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 14

so people press the buttons on the splash screen?

but why would someone hold a mirror to their screen?

TuringPesta at 2007-7-29 17:04:23 > top of Java-index,Java Essentials,Java Programming...
# 15

<slaps item="head" target="desktop"/>

BigDaddyLoveHandlesa at 2007-7-29 17:04:28 > top of Java-index,Java Essentials,Java Programming...
# 16

> so people press the buttons on the splash screen?

> but why would someone hold a mirror to their screen?

screens are like people, they tend to forget about time when they're admiring themselves and grooming their hair.

jwentinga at 2007-7-29 17:04:28 > top of Java-index,Java Essentials,Java Programming...