String[] idArray = idList.split(",");
if (result.isSuccess() == false) {
log.error("发送站内信:mobileList=" + idArray + ",content=" + content);
}
find bug会报错:
Bug: Invocation of toString on idArray
Pattern id: DMI_INVOKING_TOSTRING_ON_ARRAY, type: USELESS_STRING, category: CORRECTNESS
The code invokes toString on an array, which will generate a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.
大概意思是:
数组打印的时候:通过一个char值给println打印一个Unicode字符,而不是它的数值代码。
解决方法
To summarize, char arrays are not strings. To convert a char array to a string, invoke String.valueOf(char[]). Some library methods do provide stringlike support for char arrays, typically having one overloading for Object and another for char[]; only the latter has the desired behavior.
The lesson for language designers is that the char[] type should probably have overridden toString to return the characters contained in the array. More generally, the array types should probably have overridden toString to return a string representation of the contents of the array