导入包。* vs import package.SpecificType [英] Import package.* vs import package.SpecificType

查看:82
本文介绍了导入包。* 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?

推荐答案

没有性能或间接成本进行导入。* vs导入特定类型。但是,我认为从不使用导入是最好的做法。*我的主要原因是我只想保持事情的直接,干净和尽可能少的模棱两可,我认为用。* 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.

这篇关于导入包。* vs import package.SpecificType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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