开发者

Does Import statements sequence have any effect?

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 sa开发者_JS百科me.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜