Google的java代码规范-import规范

No wildcard imports

Wildcard imports, static or otherwise, are not used.

No line-wrapping

Import statements are not line-wrapped. The column limit (Section 4.4,
Column limit: 100) does not apply to import statements.

Ordering and spacing

Imports are ordered as follows: All static imports in a single block.
All non-static imports in a single block.
If there are both static andnon-static imports, a single blank line separates the two blocks.
There are no other blank lines between import statements.
Within each block the imported names appear in ASCII sort order.
(Note: this is not the same as the import statements being in ASCII
sort order, since ‘.’ sorts before ‘;’.)

No static import for classes

Static import is not used for static nested classes. They are imported
with normal imports.

下面是原文翻译
*1,不可使用通配符导入(即.形式的导入)

不使用通配符导入(静态或其他)。

2,不换行

导入语句不换行。列限制(第4.4节,列限制:100)不适用于导入语句。

3,排序和间距

所有静态导入都在一个块中; 所有非静态导入都在一个块中; 如果同时存在静态和非静态导入,则用一条空行分隔两个块。
除此之外,导入语句之间没有其他空行。

4,在每个导入的块中,导入顺序按照ASCII排序顺序。

注意:这与使用ASCII排序顺序的import语句不同,因为“.”在“;”之前排序。

5,没有类的静态导入

静态导入不用于静态嵌套类。它们是用正常的其他导入一起的。

发布了13 篇原创文章 · 获赞 8 · 访问量 9318

猜你喜欢

转载自blog.csdn.net/qq_43481201/article/details/90411269