简体   繁体   English

Import语句序列是否有效?

[英]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.

相关问题 EntityManager.persist 没有任何效果 - EntityManager.persist does not have any effect Java 没有任何导入别名机制,我有两个同名的导入语句 - Java doesn't have any import aliasing mechanisms, and I have two import statements with the same name Java strictfp 修饰符对现代 CPU 有什么影响吗? - Does Java strictfp modifier have any effect on modern CPUs? 将'final'关键字添加到匿名类中的方法是否有效? - Does adding the 'final' keyword to methods in anonymous classes have any effect? 在使用JDBC的查询中使用Limit是否对性能有影响? - Does using Limit in query using JDBC, have any effect in performance? Sqlite插入成功运行,但是对数据库没有任何影响吗? - Sqlite Insert Runs Successfully But Does Have not any Effect On Database? overlayPendingTransition(int,int)在onBackPressed()中没有任何作用 - overridePendingTransition(int, int) does not have any effect in onBackPressed() 导入包时我应该使用完全限定吗? 它会引起任何副作用吗? - Should I using fully-qualified when import package? Does it cause any side effect? 为什么在 Java 泛型右侧的集合类型没有任何影响? - Why in Java generics right hand side type of the collection does not have any effect? 在迭代HashMap时将对象设置为null是否对对象的状态有任何影响 - Does setting an object to null while iterating over a HashMap have any effect on the object's state
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM