title 英文详解 错误示例 中文解释
Anon Inner Length Checks for long anonymous inner
classes
匿名内部类长度限制
Avoid Array Loops Instead of copying data between
two arrays, use
System.arrayCopy method
两个数组之间复制数据,使用 System.arrayCopy方法
Avoid Assert As Identifier Finds all places 'assert' is
used as an identifier is used.
避免'assert'做为标识
Avoid Calling Finalize Object.finalize( is called by
the garbage collector on an
object when garbage collection
determines that there are no
more references to the object.
禁止使用Object.finalize(
Avoid Catching NPE Code should never throw NPE
under normal circumstances. A
catch block may hide the
original error, causing other
more subtle errors in its wake.
代码可能会抛出无法被TRY捕获 的异常.
Avoid Catching Throwable This is dangerous because it casts too wide a net; it can catch things like OutOfMemoryError.
Avoid Decimal Literals In Big Decimal Constructor One might assume that new
BigDecimal(.1 is exactly equal
to .1, but it is actually equal
to
.100000000000000005551115123125
7827021181583404541015625. This
is so because .1 cannot be
represented exactly as a double
(or, for that matter, as a
binary fraction of any finite
length. Thus, the long value
nullpointerexception为什么异常
that is being passed in to the
constructor is not exactly
equal to .1, appearances
notwithstanding. The (String
constructor, on the other hand,
is perfectly predictable: 'new
BigDecimal(.1' is exactly
equal to .1, as one would
expect. Therefore, it is
generally recommended that the
(String constructor be used in
preference to this one.
Key:
AvoidDecimalLiteralsInBigDecima
lConstructor
尽量避免BigDecimal(.1 因为 它实际上等于它实际上等 于.100000000000000005551115 123125782702118158340454101 5625.而不是0.1
Avoid Duplicate Literals Code containing duplicate
String literals can usually be