tags:

views:

65

answers:

2

I have this doubt from long time, When ever I write the class using eclipse, the import statements use to populate automatically.

Does the order of import statements have any effect 1)on the programming execution speed? 2)Any standard coding practice is there for the same.

+5  A: 

Import statements have no effect on execution speed at all. They only matter at compile-time. If you fully-qualify every name you use, the generated bytecode will be exactly the same.

As for coding conventions, I typically put all the static imports at the top, in alphabetical order, followed by other imports, in alphabetical order. Eclipse does this automatically, and also allows you to group particular third-party APIs.

By keeping the order consistent, it means you don't get as much to worry about in diffs at code review time.

Jon Skeet
+1  A: 

http://www.javaperformancetuning.com/news/qotm031.shtml

In short: import is only used by the compiler, so it will not affect runtime performance (possibly only compilation time, but usually it's negligible), and as far as I know the order doesn't matter.

Andrei Fierbinteanu