我的代码规范
- 包声明和包导入和类代码间隔空行
package test1
import test2
public class Test(){
}
- 内层代码与上层的代码无需空行
public class Test(){
public void ran(){
}
}
-
代码缩进使用4个空格
-
运算符左右各一个空格(包括三元运算符)
public class Test(){
public void ran(){
int a = 10;
int b = 12;
int c = a > b ? a : 2;
}
}
- 不同功能的代码使用空行间隔
Hello hello = new Hello();
hello.show();
hello.showStatic();
HelloSon helloSon = new HelloSon();
helloSon.show();
helloSon.showStatic();
Hello hello1 = new HelloSon();
hello1.show();
hello1.showStatic();