简体   繁体   English

Google Java风格:导入名称与导入语句?

[英]Google Java Style: Import names v.s. Import statements?

I'm looking through Google's Java Style guide and in section 3.3.3 Import Ordering and Spacing it says: 我正在查看Google的Java样式指南,并在3.3.3节“ 导入顺序和间距”中指出:

Within a group there are no blank lines, and the imported names appear in ASCII sort order. 在一个组内没有空行,并且导入的名称以ASCII排序顺序显示。 ( Note: this is not the same as the import statements being in ASCII sort order; the presence of semicolons warps the result. ) 注意:这与以ASCII排序顺序的import语句不同;分号的出现会使结​​果扭曲。

I don't get the "Note" part, could somebody please give an example? 我没有获得“注释”部分,有人可以举个例子吗?

Thanks. 谢谢。

Say you have a class with a number at the end. 假设您的班级末尾有一个数字。

If you sort the import statements 如果对导入语句进行排序

import mypackage.MyClass0;
import mypackage.MyClass;
import mypackage.MyClassA;

This is because 0 < ; 这是因为0 < ; < A in the ASCII table. < ASCII表中的< A

If you sort just the names. 如果仅对名称进行排序。

import mypackage.MyClass;
import mypackage.MyClass0;
import mypackage.MyClassA;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM