Loading...
1.【强制】 如果是大括号内为空,则简洁地写成{}即可,大括号中间无需换行和空格;如果是非空代码块则: 1) 左大括号前不换行。 2) 左大括号后换行。 3) 右大括号前换行。 4) 右大括号后还有 else 等代码则不换行;表示终止的右大括号后必须换行。 2.【强制】 左小括号和右边相邻字符之间不出现空格;右小括号和左边相邻字符之间也不出现空格;而左大括号前需要加空格。详见第 5 条...
1.【强制】 不允许任何魔法值(即未经预先定义的常量)直接出现在代码中。 反例: //本例中同学 A 定义了缓存的 key,然后缓存提取的同学 B 使用了 Id#taobao 来提取,少了下划线,导致故障。 String key = "Id#taobao_" + tradeId; cache.put(key, value);2.【强制】 在 long 或者 Long 赋值...
1.【强制】 代码中的命名均不能以下划线或美元符号 开始,也不能以下划线或美元符号 结束。 反例: _name / __name / \$name / name_ / name$ / name__ 2.【强制】 所有编程相关的命名严禁使用拼音与英文混合的方式,更不允许直接使用中文的方式。 说明:正确的英文拼写和语法可以让阅读者易于理解,避免歧义。注意,纯拼音命名方式更要避免采用。 正例:...
众所周知,HashMap 提供的访问,是无序的。而在一些业务场景下,我们希望能够提供有序访问的 HashMap 。那么此时,我们就有两种选择:TreeMap :按照 key 的顺序。LinkedHashMap :按照 key 的插入和访问的顺序。 Li...
TreeSet底层是基于TreeMap实现的,它是线程不安全的,在多线程环境下进行修改会抛异常。TreeSet是有序的,所以它的元素都必须是可比较的。成员变量private transient NavigableMap<E,Object> m; // 虚假的值,所有元素的value都是它 private s...