导入语句序列是否有效? [英] Does Import statements sequence have any effect?

查看:40
本文介绍了导入语句序列是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我长期以来一直对此表示怀疑,每当我使用eclipse编写类时,import语句都会自动填充.

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

导入语句的顺序是否有效1)关于编程执行速度?2)那里有任何标准的编码实践.

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.

推荐答案

导入语句对执行速度完全没有影响.它们仅在编译时起作用.如果您完全限定使用的每个名称,则生成的字节码将完全相同.

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.

对于编码约定,我通常将所有静态导入按字母顺序放在顶部,然后将其他静态导入按字母顺序放在顶部.Eclipse会自动执行此操作,并且还允许您对特定的第三方API进行分组.

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.

这篇关于导入语句序列是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆