[英]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. 我很长时间都有这个疑问,当我使用eclipse编写类时,import语句用于自动填充。
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.
2)任何标准编码实践都是相同的。
Import statements have no effect on execution speed at all . import语句必须在所有执行速度没有影响。 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.
Eclipse会自动执行此操作,还允许您对特定的第三方API进行分组。
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 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. 简而言之:导入仅由编译器使用,因此它不会影响运行时性能(可能只是编译时间,但通常可以忽略不计),据我所知,顺序无关紧要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.