在数组上调用toString - FindBugs

时间:2011-07-18 04:52:56

标签: arrays tostring findbugs

我的代码出现了以下Findbugs错误,

Invocation of toString on <<Package Path>>

 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. 

代码:

logger.info("Adding information"+ Employee.getName()+ " "+
            employeeForm.getQuestionAndAnswers());

请让我知道错误是什么。

1 个答案:

答案 0 :(得分:20)

正如它所说,做

myArray.toString()

会产生像java.lang.int [] @ 45345262

这样无用的东西

你想要使用

Arrays.toString(myArray);
相关问题