[hyddd的FindBugs分析记录][H C EC] equals() used to compare array and nonarray
2009-04-01 20:11 hyddd 阅读(782) 评论(0) 编辑 收藏 举报[H C EC] equals() used to compare array and nonarray [EC_ARRAY_AND_NONARRAY]
This method invokes the .equals(Object o) to compare an array and a reference that doesn't seem to be an array. If things being compared are of different types, they are guaranteed to be unequal and the comparison is almost certainly an error. Even if they are both arrays, the equals method on arrays only determines of the two arrays are the same object. To compare the contents of the arrays, use java.util.Arrays.equals(Object[], Object[]).
先看下面一段代码:
//.
If("1".equals(strs)){
//todo
}
上面这段代码,if里面的代码是永远都不会被执行的,因为我们用了一个非数据(nonarray)和一个数组(array)做equals(),这里估计是写代码时的笔误。
作者:hyddd
出处:http://www.cnblogs.com/hyddd/
本文版权归作者所有,欢迎转载,演绎或用于商业目的,但是必须说明本文出处(包含链接)。