arrays - 在数组上调用 toString - FindBugs

标签 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());

请让我知道是什么错误。

最佳答案

正如它所说,做

myArray.toString()

会产生像 java.lang.int[]@45345262 这样无用的东西

你想用
Arrays.toString(myArray);

关于arrays - 在数组上调用 toString - FindBugs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6728730/

相关文章:

python - 更改蒙版的NP数组中的值

javascript - 从数据数组中删除项目

Java 通用接口(interface)扩展了 Comparable

java - 计算小数点后的数字,包括最后一个零

sonarqube - 如何禁用 Sonar 指标中的某些问题?

arrays - Swift:将字符串中的单独字符与字典中的值匹配

javascript - 循环 K/V 对数组并查找具有最小属性的对象的最快方法

c# - 双 ToString 问题

java - 如何使用checkstyle、PMD、findbugs等工具检查java类的继承级别?

java - 如何为具有特定注释的字段设置 FindBugs 过滤器?