导入 package.* 与导入 package.SpecificType [英] Import package.* vs import package.SpecificType
问题描述
是否会假设在编写一个导入加载一个包中的所有类型的开销方面存在任何差异(import java.*
);不仅仅是特定类型(即 import java.lang.ClassLoader
)?第二种是比另一种更明智的使用方式吗?
Would it suppose any difference regarding overhead to write an import loading all the types within one package (import java.*
); than just a specific type (i.e. import java.lang.ClassLoader
)? Would the second one be a more advisable way to use than the other one?
推荐答案
导入 .* 与导入特定类型没有性能或开销成本.但是,我认为永远不要使用 import 是最佳实践.* 我这样做的主要原因是我只是喜欢让事情保持直截了当,干净并且尽可能少含糊,我认为使用 .* import 你会失去这一点.
There is not a performance or overhead cost to doing import .* vs importing specific types. However, I consider it to be a best practice to never use import .* My primary reason for this is I just like to keep things straightward, clean and with as little ambiguity as possible, and I think with a .* import you lose that.
这篇关于导入 package.* 与导入 package.SpecificType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!