Java Coding Guidelines

The style guidelines and best practices for our engineering team.

Javascript Styles


  • 2 spaces – for indentation
  • No unused variables – this one catches tons of bugs!
  • No semicolons – It's fine. Really!
  • Never start a line with ( , [ , or ```
  • Space after keywords if (condition) { ... }
  • Always use === instead of == – but obj == null is allowed to check null || undefined .

编译错误集


QuestionAnswer
错误: 不兼容的类型: String无法转换为int int xueHao = "110";int xueHao = 110;
错误: 找不到符号 int xingMing = 张三;int 张三 = 100; int xingMing = 张三;
错误: 不兼容的类型: String无法转换为int int xingMing = "张三";String xingMing = "张三";
错误: 不兼容的类型: String无法转换为char char c4 = "a";char c4 = ‘a’;
错误: 未结束的字符文字 char c5 = 'ab';char c5 = 'a';
错误: 未结束的字符文字 System.out.println('');System.out.println('\');
错误: 空字符文字 System.out.println(''');System.out.println(’’’);
错误: 需要')' System.out.println(""YUNKECANG"");错误: 需要')' System.out.println(""YUNKECANG"");
错误: 整数太大 long e = 2147483648;错误: 整数太大 long e = 2147483648L;
错误: 不兼容的类型: 从long转换到int可能会有损失 long x = 100; int y = x;long x = 100; int y = int(x);
错误: 不兼容的类型: 从int转换到short可能会有损失char c1 = 'a'; byte b = 1; short c = c1 + b;char c1 = 'a'; byte b = 1; short c = (short)(c1 + b);
错误: 不兼容的类型: 从double转换到float可能会有损失 float f = 3.14;float f = 3.14F;或者float f = (float)3.14;
错误: 不兼容的类型: 从double转换到int可能会有损失 int i = 10.0 / 5;int i = (int)10.0 / 5;或者int i = (int)(10.0 / 5);
错误: 不兼容的类型: int无法转换为boolean boolean xingBie = 1;boolean xingBie = true;

运行错误集


QuestionAnswer

发表评论